rt 附上代码大佬可以看看哪里错了吗
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
int n;
int a[200005];
int sum[200005];
bool check(int l, int r) {
int g = sum[r] - sum[l - 1];
cout << "?" << " " << r - l + 1 << " " << endl;
fflush(stdout);
for (int i = l; i <= r; i++) {
cout << i << " ";
}
cout << endl;
fflush(stdout);
int x;
cin >> x;
if (g != x) {
return 1;
} else return 0 ;
}
void solve() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n; i++) {
sum[i] = sum[i - 1] + a[i];
}
int l = 1;
int r = n;
while (l <= r) {
int mid = l + r >> 1;
if (check(l, mid)) {
if (mid - l + 1 == 1) {
cout << "!" << " " << l << endl;
fflush(stdout);
return ;
} else if (mid - l + 1 == 2) {
cout << "? " << 1 << " " << l << endl;
fflush(stdout);
int hs;
cin >> hs;
if (hs == a[l]) {
cout << "!" << " " << mid << endl;
fflush(stdout);
} else {
cout << "! " << l << endl;
fflush(stdout);
}
return ;
}
else r = mid - 1;
} else l = mid + 1;
}
}
signed main() {
int t;
ios::sync_with_stdio();
cin.tie(0);
cout.tie(0);
cin >> t;
while (t--)solve();
return 0;
}