题目地址:https://codeforces.com/contest/1486/problem/C2
另一道入门交互题:https://codeforces.com/contest/679/problem/A
- 题目:
大小为 n = 1 0 5 n=10^5 n=105的数组,每次询问为 ? l r ?\ l\ r ? l r 格式,询问 [ l , r ] [l,r] [l,r]区间的次大值在整个数组中的位置(从 1 1 1开始)。
在最多进行 20 20 20次询问之后,以 ! p o s !\ pos ! pos 的格式输出最大值在数组中的位置 p o s pos pos。
input:
5
3
4
output:
? 1 5
? 4 5
! 1
- 思路:
- 首先询问 ? 1 n ?\ 1\ n ? 1 n,获得整个数组中次大值的位置 p 1 p1 p