#P8573. 「DTOI-2」星之灵
「DTOI-2」星之灵
Background
Small Reminder
- Pay attention to the letter case of .
Problem Description
Brief Statement
Repeatedly input strings, where:
- When the input string is , the letter case of all subsequent strings is toggled until the next appears.
- Given queries, each query asks for the -th string that is not .
Original Statement
The Spirit of the Stars can speak sentences to you, and you need to record them.
Each sentence may be a string not equal to , or it can be a command . The command controls the letter case of all letters spoken by the Spirit of the Stars. When is spoken once, all lowercase letters spoken afterwards must be changed to uppercase, and all uppercase letters must be changed to lowercase. When is spoken the second time, it returns to normal, and so on. In particular, for the command spoken by the Spirit of the Stars, you do not need to record it.
The Spirit of the Stars will keep repeating these sentences without changing the order, and it has queries. For each query, you need to tell the Spirit of the Stars what the -th sentence you recorded is.
Input Format
This problem uses multiple test cases.
The first line contains an integer .
The next line contains strings.
The third line contains an integer .
The next lines each contain a positive integer .
The meanings of are as described in the statement.
Output Format
Output lines, each containing a string, corresponding to the answer for one query.
5
CapsLock CapsLock a CapsLock B
4
1
2
3
4
a
b
A
B
7
h W CapsLock I CapsLock j CapsLock
8
7
9
13
45
20
28
50
101
I
h
H
H
j
j
W
H
10
Oh P CapsLock CapsLock CapsLock Cv Ts CapsLock XU AR
10
84
63
414
149
25
61
50
4043
9111
47
AR
cV
AR
XU
Oh
Oh
P
XU
cV
XU
Hint
Explanation for Sample #1
The first four recorded sentences are: .
Constraints
| Special Property | Score | |||
|---|---|---|---|---|
| / | ||||
For all testdata, , .
Property : There is no among the input strings.
Data Guarantee
- Among all sentences, there is at least one string that is not .
- The length of every input string is at most .
- All input strings are non-empty and contain only uppercase and lowercase letters.
Translated by ChatGPT 5