#P13996. 【MX-X19-T5】「FeOI Round 4.5」天使のクローバー
【MX-X19-T5】「FeOI Round 4.5」天使のクローバー
Description
Minori has a sequence , initially . The indices of this sequence start from .
For a sequence with indices starting from , define the new sequence obtained after one -transformation as:
- Initially, is empty.
- For each , append to the end of :
- copy of (if );
- copies of (if ).
- The indices of also start from .
For example, , and .
For a non-negative integer , define the notation as the sequence obtained by applying the -transformation to consecutively times.
Minori will give you queries. Each query provides two non-negative integers , and asks for the value of the element at index in . If the length of is , meaning there is no element at index , you must report that.
Input Format
The first line contains a positive integer .
The next lines each contain two non-negative integers .
Output Format
For each query, output one line. If an element at index exists, output a non-negative integer representing its value; otherwise, output -1.
3
1 3
1 4
2 4
1
-1
0
Hint
【Sample Explanation】
The initial sequence is .
After one transformation, the sequence becomes .
After two transformations, the sequence becomes .
【Data Range】
The test cases are not equally weighted. See the score column for details.
| Test Case ID | Special Properties | Score | ||
|---|---|---|---|---|
| None | ||||
| No answer is | ||||
| None |
For all test cases, , .
Translated by DeepSeek V3.1
京公网安备 11011102002149号