#P111. [TFXOI Round 1] 我欲于群山之巅
[TFXOI Round 1] 我欲于群山之巅
Source
This problem is proposed by . All rights reserved.
Problem Source: https://www.luogu.com.cn/problem/T565373
Problem Background
I wish to stand atop the mountains, gazing at the starry Milky Way above and the vast world below.
Problem Description
This is an interactive problem.
The "God" is touring the "world" he created.
He sees a mountain range of length with strictly increasing heights (i.e., peaks with heights in strictly ascending order).
Thus, "God" wants to climb the highest peak to enjoy the view, and you need to tell him the position of the highest peak.
However, he thinks this problem is too simple for you, so he will perform modifications, each time raising or lowering the heights of the peaks in the interval by a certain amount. After each modification by "God," you need to tell him the position of the highest peak (if there are multiple, any one is acceptable).
Of course, you may not have the divine power to know the exact height of each peak like "God," so after each operation, you can ask "God" no more than times to compare the heights of two peaks and . If "God" answers 0, it means ; if the answer is 1, it means .
Input Format
The first line contains three integers .
Then, lines follow, each containing two integers .
Output Format
If you need to ask "God" about the height comparison between peaks and , output ? x y.
If you want to tell "God" the position of the highest peak, output ! x.
Samples
5 3 100
1 2
0
2 4
0
1
1 2
1
? 2 5
! 5
? 1 2
? 4 5
! 4
? 2 4
! 2
Sample Explanation
Initially, the mountain heights are: .
The first operation adds to the interval , changing the heights to: .
The second operation adds to the interval , changing the heights to: .
The third operation adds to the interval , changing the heights to: .
Data Range
This problem uses bundled tests.
- For all data:
- .
- .
- .
- .
- .
Your provided must satisfy .
The time complexity for each SPJ response is .
Please flush the buffer after each output. You can use the following commands to flush the buffer:
- For C/C++:
fflush(stdout); - For C++:
std::cout << std::flush; - For Java:
System.out.flush(); - For Python:
stdout.flush(); - For Pascal:
flush(output); - For other languages, please refer to their respective documentation.
- Specifically for C++, using
std::endlinstead of'\n'will automatically flush the buffer.
| Subtask ID | Points | |||
|---|---|---|---|---|
| 1 | 5 | |||
| 2 | 35 | |||
| 3 | 60 |