문제
Bessie finds a string of length at most containing only the three characters 'C', 'O', and 'W'. She wants to know if it's possible to turn this string into a single 'C' (her favorite letter) using the following operations:
-
Choose two adjacent equal letters and delete them.
-
Choose one letter and replace it with the other two letters in either order.
Finding the answer on the string itself isn't enough for Bessie, so she wants to know the answer for () substrings of .
입력
The first line contains .
The next line contains .
The next lines each contain two integers and (, where denotes the length of ).
출력
A string of length , with the -th character being 'Y' if the -th substring can be reduced and 'N' otherwise.
예제 입력 1
COW
6
1 1
1 2
1 3
2 2
2 3
3 3
예제 출력 1
YNNNYN
점수
Test cases 2-4 satisfy and .Test cases 5-11 satisfy no additional constraints.
코드를 제출하려면 로그인이 필요합니다.
로그인