atcoder#MUJINPC2017C. Robot and String
Robot and String
Score : points
Problem Statement
You are developing a robot that processes strings. When the robot is given a string consisting of lowercase English letters, it processes the string by following the procedure below:
- Let be the smallest index such that . If such an index does not exist, terminate the procedure.
- If is
z
, remove and from . Otherwise, let be the next letter of in the English alphabet, and replace and together with , reducing the length of by . - Go back to step 1.
For example, when the robot is given the string axxxxza
, it will be processed as follows: axxxxza
→ ayxxza
→ ayyza
→ azza
→ aa
→ b
.
You are given a string consisting of lowercase English letters. Answer queries. The -th query is as follows:
- Assume that the robot is given a substring of that runs from the -th character and up to the -th character (inclusive). Will the string be empty after processing?
Constraints
- consists of lowercase English letters.
Input
The input is given from Standard Input in the following format:
Output
Print lines.
The -th line should contain the answer to the -th query: Yes
or No
.
axxxxza
2
1 7
2 6
No
Yes
- Regarding the first query, the string will be processed as follows:
axxxxza
→ayxxza
→ayyza
→azza
→aa
→b
. - Regarding the second query, the string will be processed as follows:
xxxxz
→yxxz
→yyz
→zz
→ ``.
aabcdefghijklmnopqrstuvwxyz
1
1 27
Yes
yzyyyzyzyyyz
8
1 6
7 12
1 12
6 11
1 1
1 3
4 9
3 8
Yes
Yes
Yes
Yes
No
No
No
No