atcoder#AGC034A. [AGC034A] Kenken Race
[AGC034A] Kenken Race
Score : points
Problem Statement
There are squares arranged in a row, numbered from left to right.
You are given a string of length consisting of .
and #
. If the -th character of is #
, Square contains a rock; if the -th character of is .
, Square is empty.
In the beginning, Snuke stands on Square , and Fnuke stands on Square .
You can repeat the following operation any number of times:
- Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.
You want to repeat this operation so that Snuke will stand on Square and Fnuke will stand on Square .
Determine whether this is possible.
Constraints
- is a string of length consisting of
.
and#
. - Square , , and do not contain a rock.
- , , and are all different.
Input
Input is given from Standard Input in the following format:
Output
Print Yes
if the objective is achievable, and No
if it is not.
7 1 3 6 7
.#..#..
Yes
The objective is achievable by, for example, moving the two persons as follows. (A
and B
represent Snuke and Fnuke, respectively.)
A#B.#..
A#.B#..
.#AB#..
.#A.#B.
.#.A#B.
.#.A#.B
.#..#AB
7 1 3 7 6
.#..#..
No
15 1 3 15 13
...#.#...#.#...
Yes