#P8263. [Ynoi Easy Round 2020] TEST_8
[Ynoi Easy Round 2020] TEST_8
Problem Description
Given a string of length (a sequence consisting of and , indexed by integers from to ).
The following operations are supported:
Operation 1: given , repeat the substring of the string from index to for times and put it back in place.
Operation 2: given , repeat the substring of the string from index to for times with reversal (specifically, for the -th repetition (), if the binary representation of contains an odd number of , then this repetition should be reversed left to right; otherwise it remains unchanged), and finally put it back in place.
Operation 3: given , delete the substring of the string from index to .
Operation 4: given , find the position of the -th in the string from left to right. If exceeds the number of in the string, output .
Input Format
The first line contains an integer .
The next line contains a string of length .
The next line contains an integer .
The next lines each start with an integer indicating the operation type.
If or , the line then contains three integers .
If , the line then contains two integers .
If , the line then contains one integer .
Output Format
For each operation 4, output one line representing the answer.
11
11011100010
5
3 2 3
2 6 8 5
1 2 5 3
4 8
4 100
10
-1
Hint
Idea: ccz181078, Solution: ccz181078, Code: ccz181078, Data: ccz181078.
It is guaranteed that the length of the string before the operation.
In operations , .
For of the testdata, , and the length of the string never exceed .
For of the testdata, there is only one operation 4, and there is no operation 2.
For of the testdata, , and the length of the string never exceeds .
Sample explanation:
The 1st operation: 1[10]11100010->111100010, deleted 10.
The 2nd operation: 11110[001]0->11110[001,100,100,001,100]0->111100011001000011000, repeated 001 for 5 times, where the 2nd, 3rd, and 5th times are reversed.
The 3rd operation: 1[1110]0011001000011000->1[1110,1110,1110]0011001000011000->11110111011100011001000011000, repeated 1110 for 3 times.
The 4th operation: 111101110[1]1100011001000011000, the 8th is at the 10th position in the string.
The 5th operation: there is no 100th , output -1.
Translated by ChatGPT 5