diff --git a/Codeforces/1698/D/D.cpp b/Codeforces/1698/D/D.cpp new file mode 100644 index 00000000..483c1060 --- /dev/null +++ b/Codeforces/1698/D/D.cpp @@ -0,0 +1,44 @@ +#include + +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; +}