## CPC '19 Contest 1 P3 - Admiral Kuznetsov

View as PDF

Points: 12 (partial)
Time limit: 0.6s
Memory limit: 256M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Aircraft carrier Admiral Kuznetsov's deck can hold up to aircraft in line. Today's challenge will be to reach a certain aircraft configuration in the shortest time possible.

All aircraft are on deck with their crews. In one unit of time, one of three things can happen:

1. Four aircraft in consecutive spots simultaneously take off in formation.

2. Three aircraft in consecutive spots simultaneously take off in formation.

3. One aircraft lands at an empty spot on deck.

There are an infinite number of land-based aircraft in the air, so the third operation can always be called.

#### Constraints

(new cases for in addition to contest data)

#### Input Specification

The first line contains integer .

The next line contains a string of length , with representing an aircraft present and representing an empty spot on the deck.

The next line contains a string of length , with representing an aircraft and representing an empty spot in the final configuration.

#### Output Specification

Output the minimum units of time required to reach the final configuration.

If the final configuration can not be reached, print -1.

#### Sample Input 1

7
1100111
0000000

#### Sample Output 1

3

#### Explanation

One aircraft lands at position .

Aircraft take off.

Aircraft take off.

• commented on May 14, 2019, 3:39 p.m.

What code is expect the problem?

• commented on May 14, 2019, 3:42 p.m.

Aim to get an IE

• commented on May 14, 2019, 10:02 a.m.

RoronoaZoro is get WA. What mean WA?

• commented on May 14, 2019, 12:00 p.m.

WA stands for "Wrong Answer", which indicates that the submitted code is outputting an answer different from what the problem is expecting.