## DMOPC '18 Contest 5 P4 - An Art Gallery Problem

View as PDF

Points: 12 (partial)
Time limit: 1.0s
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

Bob is admiring a beautiful postmodern exhibit at the local art gallery. The exhibit consists of colourful neon lamps in a line, labelled to , and each lamp can be one of two colours: a vibrant fuchsia or a soothing aquamarine.

The exhibit also happens to be interactive. There are buttons that the visitors can press, labelled to . Pressing button will simultaneously change the colours of lamps and (from fuchsia to aquamarine or aquamarine to fuchsia), but only if those lamps are the same colour. Obviously, this represents the profound fragility and changeable nature of the human condition.

Bob notices that the colours of the lamps currently form pattern . He thinks they would look good in pattern , so he wants to know if it is possible to get to from by a sequence of zero or more button presses.

#### Input Specification

The first line will contain one integer, .
The second line will contain a string of characters, either F (fuchsia) or A (aquamarine), pattern .
The third and final line will contain a string of characters, either F or A, pattern .

#### Output Specification

Output YES if it is possible to get to from and NO otherwise.

#### Sample Input 1

6
FAAFFF
FFAAFF

#### Sample Output 1

YES

#### Sample Input 2

6
FAFAFA
AFAFAF

#### Sample Output 2

NO