LaLa and Lamp
시간 제한3초메모리 제한1024 MB
삼각형 격자의 전구 상태가 주어질 때, 세 방향의 행 전체를 뒤집는 마법만으로 모든 전구를 끌 수 있는지 판정한다.
문제
When laid down on her pet 's back to fall asleep, she noticed that the lamp is all messed up, which must have been the act of her sister .
The lamp can be modeled as a regular triangular grid where each cell contains a bulb which is either on or off.
wants to turn off the lamp (that is, set the state of all bulbs to off). can pick any of the three directions parallel to the side of a lamp, pick any row parallel to that direction, and then flip the state of all the bulbs in the row (on to off and off to on) with her . also could just walk over to the lamp and manually turn every bulb off, but she would prefer not to.
Write a program that determines whether can turn off the lamp with her .
입력
The input is given in the following format:
where is the number of bulbs in a side of the lamp, and is the binary string of length representing the initial states of bulbs in the -th row, where the -th character of is '1' if and only if the -th bulb is on.
The input satisfies the following constraint:
- is an integer.
출력
If can turn off the lamp with , print a single string "Yes". Otherwise, print a single string "No". You may print each character in either case (lower or upper).
힌트
The following illustrates a sequence of should cast to turn off the lamp given in the sample. Empty circles denote the bulbs that are off, yellow circles denote the bulbs that are on, and red line is the choosen row for .






