-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathD.cpp
100 lines (100 loc) · 2.33 KB
/
D.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// LUOGU_RID: 160024155
//A tree without skin will surely die.
//A man without face is invincible.
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for (int i=j;i<=k;++i)
#define per(i,j,k) for (int i=j;i>=k;--i)
int const N=505;
int n,a[N],vis[N],tot;
inline bool ask(int u,int k,vector<int>S){
cout<<"? "<<u<<' '<<k<<' '<<S.size()<<' ';
for (auto it:S) cout<<it<<' ';
cout<<endl;
int rd;cin>>rd;
return rd;
}
inline int work(int x,int bu){
vector<int>V;
rep(i,1,n) V.push_back(i);
while (V.size()>1){
vector<int>K;
int len=V.size();
rep(i,0,len/2-1) K.push_back(V[i]);
if (ask(x,bu,K)) V=K;
else{
K.clear();
rep(i,len/2,len-1) K.push_back(V[i]);
V=K;
}
}
return V[0];
}
inline bool getqry(int u,int bu){
cout<<"? "<<u<<' '<<bu<<' '<<tot<<' ';
rep(i,1,tot) cout<<a[i]<<' ';
cout<<endl;
int rd;cin>>rd;
return rd;
}
inline void print(){
cout<<"! "<<tot<<' ';
sort(a+1,a+tot+1);
rep(i,1,tot) cout<<a[i]<<' ';
cout<<endl;
}
void solve(){
cin>>n,a[++tot]=work(1,1e8),vis[a[tot]]=1;
rep(i,1,63){
int T=work(a[tot],1);
if (T==a[1]) break;
a[++tot]=T,vis[T]=1;
}
if (tot<63){
rep(i,1,n){
if (vis[i]) continue;
if (getqry(i,1e8)) vis[i]=1,a[++tot]=i;
}
print();
return;
}
rep(i,1,n){
if (vis[i]) continue;
if (getqry(i,63)) vis[i]=1,a[++tot]=i;
}
if (tot<63*2){
rep(i,1,n){
if (vis[i]) continue;
if (getqry(i,1e8)) vis[i]=1,a[++tot]=i;
}
print();
return;
}
rep(i,1,n){
if (vis[i]) continue;
if (getqry(i,63*2)) vis[i]=1,a[++tot]=i;
}
if (tot<63*4){
rep(i,1,n){
if (vis[i]) continue;
if (getqry(i,1e8)) vis[i]=1,a[++tot]=i;
}
print();
return;
}
rep(i,1,n){
if (vis[i]) continue;
if (getqry(i,63*4)) vis[i]=1,a[++tot]=i;
}
rep(i,1,n){
if (vis[i]) continue;
if (getqry(i,1e8)) vis[i]=1,a[++tot]=i;
}
print();
}
signed main(){
int t=1;
// cin>>t;
while (t--) solve();
return 0;
}