#L10285. [USACO24OPEN] Activating Robots P
[USACO24OPEN] Activating Robots P
CF1920D Array Repetition
题目描述
Jayden has an array which is initially empty. There are operations of two types he must perform in the given order.
- Jayden appends an integer ( ) to the end of array .
- Jayden appends copies of array to the end of array . In other words, array becomes . It is guaranteed that he has done at least one operation of the first type before this.
Jayden has queries. For each query, you must tell him the -th element of array . The elements of the array are numbered from .
输入格式
Each test consists of multiple test cases. The first line contains a single integer ( ) — the number of test cases. The description of the test cases follows.
The first line of each test case contains two integers and ( ) — the number of operations and the number of queries.
The following lines describe the operations. Each line contains two integers and ( ), where denotes the type of operation. If , then ( ) is the integer Jayden appends to the end of the array. If , then ( ) is the number of copies Jayden appends to the end of the array.
The next line of each test case contains integers ( ), which denote the queries, where is the size of the array after finishing all operations.
It is guaranteed that the sum of and the sum of over all test cases does not exceed .
输出格式
For each test case, output integers — answers to Jayden's queries.
输入输出样例 1
4
5 10
1 1
1 2
2 1
1 3
2 3
1 2 3 4 5 6 14 15 16 20
10 10
1 3
1 8
2 15
1 6
1 9
1 1
2 6
1 1
2 12
2 10
32752 25178 3198 3199 2460 2461 31450 33260 9016 4996
12 5
1 6
1 11
2 392130334
1 4
2 744811750
1 10
1 5
2 209373780
2 178928984
1 3
2 658326464
2 1000000000
914576963034536490 640707385283752918 636773368365261971 584126563607944922 1000000000000000000
2 2
1 1
1 2
1 2
1 2 1 2 3 1 2 3 1 3
9 8 1 3 1 3 6 3 8 8
11 11 11 10 11
1 2
说明/提示
In the first test case:
- After the first operation ;
- After the second operation ;
- After the third operation ;
- After the fourth operation ;
- After the fifth operation $ a = [1, 2, 1, 2, 3, 1, 2, 1, 2, 3, 1, 2, 1, 2, 3, 1, 2, 1, 2, 3] $ .
In the fourth test case, after all operations .