#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 nn with strictly increasing heights (i.e., nn peaks with heights a1ana_1\sim a_n 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 mm modifications, each time raising or lowering the heights of the peaks in the interval [l,r][l, r] 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 kk times to compare the heights of two peaks xx and yy. If "God" answers 0, it means ax<aya_x < a_y; if the answer is 1, it means axaya_x \ge a_y.

Input Format

The first line contains three integers n,m,kn, m, k.

Then, mm lines follow, each containing two integers l,rl, r.

Output Format

If you need to ask "God" about the height comparison between peaks xx and yy, output ? x y.

If you want to tell "God" the position xx 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: {1,2,3,4,5}\{1,2,3,4,5\}.
The first operation adds 11 to the interval [1,2][1,2], changing the heights to: {2,3,3,4,5}\{2,3,3,4,5\}.
The second operation adds 22 to the interval [2,4][2,4], changing the heights to: {2,5,5,6,5}\{2,5,5,6,5\}.
The third operation adds 33 to the interval [1,2][1,2], changing the heights to: {5,8,5,6,5}\{5,8,5,6,5\}.

Data Range

This problem uses bundled tests.

  • For all data:
    • 1n1051 \le n \le 10^5.
    • 1m1041 \le m \le 10^4.
    • 34k10534 \le k \le 10^5.
    • 1lrn1 \le l \le r \le n.
    • 1a1<a2<<an1091 \le a_1 < a_2 < \ldots < a_n \le 10^9.

Your provided x,yx, y must satisfy 1x,yn1 \le x, y \le n.

The time complexity for each SPJ response is O(logn)O(\log n).

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::endl instead of '\n' will automatically flush the buffer.
Subtask ID nn mm kk Points
1 10\le 10 10\le 10 105\ge 10^5 5
2 105\le 10^5 100\ge 100 35
3 104\le 10^4 34\ge 34 60