#587
Unrated
COW Operations
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Bessie finds a string ss of length at most 21052 \cdot 10^5 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:

  1. Choose two adjacent equal letters and delete them.

  2. 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 QQ (1Q21051\le Q\le 2\cdot 10^5) substrings of ss.

입력

The first line contains ss.

The next line contains QQ.

The next QQ lines each contain two integers ll and rr (1lrs1\le l\le r\le |s|, where s|s| denotes the length of ss).

출력

A string of length QQ, with the ii-th character being 'Y' if the ii-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 s5000|s|\le 5000 and Q5000Q\le 5000.Test cases 5-11 satisfy no additional constraints.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.