提交记录
#include <bits/stdc++.h>
#define debug cout<<"*********\n";
using namespace std;
int n,smax,k,cnt;
struct st{
int l;
int r;
int size;
int v[205];
int vis(int x){
if(x<l || x>r) return 0;
else return v[x];
}
void add(int x,int d){v[x]+=d;}
};
st last[50];
inline st new_st(int l,int r,int f=0){
st nst;nst.l = l;nst.r = r;nst.size = (r-l)+1;
for(int i=l;i<=r;i++) nst.v[i] = f;
return nst;
}
inline void last_add(st x){last[cnt] = x;cnt++;}
inline st merge(st a,st b){
st nst = new_st(min(a.l,b.l),max(a.r,b.r));
nst.size = 0;
for(int i=nst.l;i<=nst.r;i++){
nst.add(i,a.vis(i)+b.vis(i));
nst.size+=a.vis(i)+b.vis(i);
}
return nst;
}
inline char ques_null(){
cout<<"? 0"<<endl;
char c;cin>>c;return c;
}
inline void print(st a){
cout<<a.size<<" ";
for(int i=a.l;i<=a.r;i++){
for(int j=1;j<=a.vis(i);j++){
cout<<i<<" ";
}
}
cout<<endl;
}
inline char ques(st a){
cout<<"? ";
print(a);
char c;cin>>c;
return c;
}
inline bool state(int x,int sta){return (sta&((1<<x)-1))>>(x-1);}
char generate(st now){
char c;
if(cnt==0) c = ques(now);
else{
int nq = 1<<(cnt-1);
for(int i=0;i<nq;i++){
st ns = last[0];
bool empty = 1;
for(int j=1;j<cnt;j++){
if(state(j,i)){
ns = merge(ns,last[j]);
}
}
ns = merge(ns,now);
c = ques(ns);
}
}
return c;
}
inline char opst(char a,char b){return a=='+' && b=='-' || a=='-' && b=='+';}
void solve(st x,char lst){
int mid = (x.l+x.r-1)/2;
st lf = new_st(x.l,mid,1);st rt = new_st(mid+1,x.r,1);
char nc;
if(lst=='0'){
cnt = 0;
nc = ques(lf);
last_add(lf);
if(nc=='-') solve(lf,nc);
else solve(rt,nc);
}
else{
nc = generate(lf);
last_add(lf);
if(opst(nc,lst) || nc=='0'){
if(lf.size==1) cout<<"! "<<lf.l<<endl;
else solve(lf,nc);
}
else{
if(rt.size==1) cout<<"! "<<rt.l<<endl;
else{
solve(rt,nc);
}
}
}
}
int main(){
int t;
cin>>t;
for(int tt=0;tt<t;tt++){
cnt = 0;
cin>>n>>smax>>k;
solve(new_st(1,n,1),'0');
}
return 0;
}