#abc340b. B - Append
B - Append
Score: points
问题描述
你有一个空的序列 。有 个查询操作需要按照给定顺序进行处理。
查询操作有两种类型:
1 x
: 将数值 添加到序列 的末尾。2 k
: 从序列 的末尾开始找到第 个值。当此查询给出时,保证序列 的长度至少为 。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You have an empty sequence . There are queries given, and you need to process them in the order they are given.
The queries are of the following two types:
1 x
: Append to the end of .2 k
: Find the -th value from the end of . It is guaranteed that the length of is at least when this query is given.
Constraints
- In the first type of query, is an integer satisfying .
- In the second type of query, is a positive integer not greater than the current length of sequence .
Input
The input is given from Standard Input in the following format:
Each query is in one of the following two formats:
Output
Print lines, where is the number of queries of the second type.
The -th line should contain the answer to the -th such query.
Sample Input 1
5
1 20
1 30
2 1
1 40
2 3
Sample Output 1
30
20
- Initially, is empty.
- The first query appends to the end of , making .
- The second query appends to the end of , making .
- The answer to the third query is , which is the -st value from the end of .
- The fourth query appends to the end of , making .
- The answer to the fifth query is , which is the -rd value from the end of .
update @ 2024/3/10 01:32:30