Logo
(追記) (追記ここまで)

24979번 - COW Operations 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 1024 MB22915813669.388%

문제

Bessie finds a string $s$ of length at most 2ドル \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 $Q$ (1ドル\le Q\le 2\cdot 10^5$) substrings of $s$.

입력

The first line contains $s$.

The next line contains $Q$.

The next $Q$ lines each contain two integers $l$ and $r$ (1ドル\le l\le r\le |s|,ドル where $|s|$ denotes the length of $s$).

출력

A string of length $Q,ドル with the $i$-th character being 'Y' if the $i$-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

힌트

The answer to the first query is yes because the first character of $s$ 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 $s$ can be converted into 'C' in two operations:

 OW
-> CWW
-> C

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

출처

Olympiad > USA Computing Olympiad > 2021-2022 Season > USACO 2022 US Open Contest > Silver 3번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /