mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 03:31:59 +00:00
D - Fixed Point Guessing
https://codeforces.com/contest/1698/submission/162148239
This commit is contained in:
parent
251274fc67
commit
1a0a51962d
44
Codeforces/1698/D/D.cpp
Normal file
44
Codeforces/1698/D/D.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
#include <iostream>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
int t, n, ans;
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
|
||||
cin >> t;
|
||||
|
||||
while (t--) {
|
||||
ans = 0;
|
||||
|
||||
cin >> n;
|
||||
|
||||
int l = 1, r = n;
|
||||
|
||||
while (l <= r) {
|
||||
int mid = l + r >> 1;
|
||||
cout << "? " << 1 << ' ' << mid << endl;
|
||||
|
||||
int cnt = 0;
|
||||
for (int i = 1, x; i <= mid; i++) {
|
||||
cin >> x;
|
||||
|
||||
if (x <= mid) cnt++;
|
||||
}
|
||||
|
||||
if (cnt & 1) {
|
||||
r = mid - 1;
|
||||
ans = mid;
|
||||
} else {
|
||||
l = mid + 1;
|
||||
}
|
||||
}
|
||||
|
||||
cout << "! " << ans << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user