아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

COW Operations

시간 제한2초메모리 제한1024 MB

요약
C, O, W로 이루어진 문자열에서 두 가지 연산을 사용해 부분 문자열을 하나의 C로 줄일 수 있는지 각 질의마다 판정한다.
난이도

보통10점 중 7점

유형
문자열, 누적 합, 수학
정답자
아직 제출이 없습니다

문제

Bessie finds a string ss of length at most 2⋅1052 \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 (1≤Q≤2⋅1051\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 (1≤l≤r≤∣s∣1\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.

힌트

The answer to the first query is yes because the first character of ss is already equal to 'C'.

The answer to the fifth query is yes because the substring OW from the second to the third character of ss can be converted into 'C' in two operations:

   OW
-> CWW
-> C

No other substring of this example string COW can be reduced to 'C'

예제1

  1. 예제 1

    입력
    COW
    6
    1 1
    1 2
    1 3
    2 2
    2 3
    3 3
    
    예상 출력
    YNNNYN