Created
March 19, 2023 17:11
-
-
Save qjatn0120/3f69cd3f24de35d030f620c4065ba8d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int query(int l, int r){ | |
cout << "? "; | |
cout << (r - l + 1) << " "; | |
for(int i = l; i <= r; i++){ | |
cout << i; | |
if(i == r) cout << endl; | |
else cout << " "; | |
} | |
int res; | |
cin >> res; | |
return res; | |
} | |
int main(){ | |
cin.tie(nullptr), ios::sync_with_stdio(false); | |
int t; | |
cin >> t; | |
while(t--){ | |
int n; | |
cin >> n; | |
vector <int> a(n + 1); | |
for(int i = 1; i <= n; i++){ | |
cin >> a[i]; | |
a[i] += a[i - 1]; | |
} | |
int l = 1, r = n; | |
while(l < r){ | |
int mid = (l + r) >> 1; | |
if(query(l, mid) != a[mid] - a[l - 1]) r = mid; | |
else l = mid + 1; | |
} | |
cout << "! " << l << endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment