-
Notifications
You must be signed in to change notification settings - Fork 0
/
E.cpp
44 lines (42 loc) · 938 Bytes
/
E.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
long long ara[200005];
int main()
{
fastio;
long long t,n,m,i,low,mid,high;
cin>>t;
while(t--)
{
cin>>n;
for(i=1;i<=n;i++)
cin>>ara[i];
ara[0]=0;
for(i=1;i<=n;i++)
ara[i]+=ara[i-1];
low=1;
high=n;
while(low<=high)
{
mid=low+(high-low)/2;
cout<<"? "<<mid-low+1<<" ";
for(i=low;i<=mid;i++)
cout<<i<<" ";
cout<<endl;
long long x;
cin>>x;
if(low==mid && ara[low]-ara[low-1]<x)
{
cout<<"! "<<low<<endl;
break;
}
if(x==ara[mid]-ara[low-1])
low=mid+1;
else
high=mid;
}
}
return 0;
}