#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
using namespace std;
int N,cnt=1,A[151];
vector<int> ss;
void ask(int cur,int l,int r) {
int w = 1+(r-l+1);
cout<<w<<' '<<cur<<' ';
for (int i=l;i<=r;i++)
cout<<ss[i]<<' ';
cout<<endl;
}
int main() {
cin>>N;
for (int i=1;i<=N;i++)
ss.push_back(i);
while (!ss.empty()) {
int cur=*ss.begin(),ans,ans1,ans2;
ss.erase(ss.begin());
A[cur]=cnt;
vector<pair<int,int>> temp;
temp.push_back({0,(int)ss.size()-1});
while (!temp.empty()) {
int l = temp.back().f;
int r = temp.back().s;
int mid = (l+r)>>1;
temp.pop_back();
if (l > r) continue;
if (r==l) {
ask(cur,l,l);
cin>>ans;
if (ans==1) {
A[ss[l]]=cnt;
ss.erase(ss.begin()+l);
}
continue;
}
ask(cur,l,r);
cin>>ans1;
if (ans1==1) {
for (int i=l;i<=r;i++)
A[ss[i]]=cnt;
ss.erase(ss.begin()+l,ss.begin()+r+1);
continue;
}
ask(ss[l],l+1,r);
cin>>ans2;
if (ans1!=ans2)
continue;
temp.push_back({l,mid});
temp.push_back({mid+1,r});
}
cnt++;
}
cout<<"0 ";
for (int i=1;i<=N;i++)
cout<<A[i]<<' ';
cout<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
384 KB |
Output is correct |
2 |
Correct |
15 ms |
384 KB |
Output is correct |
3 |
Correct |
7 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
4 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
20 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
256 KB |
Output is correct |
2 |
Correct |
11 ms |
256 KB |
Output is correct |
3 |
Correct |
9 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
252 KB |
Output is correct |
5 |
Correct |
6 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
256 KB |
Output is correct |
7 |
Correct |
6 ms |
304 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
14 ms |
256 KB |
Output is correct |
3 |
Correct |
10 ms |
256 KB |
Output is correct |
4 |
Correct |
8 ms |
256 KB |
Output is correct |
5 |
Correct |
4 ms |
512 KB |
Output is correct |
6 |
Correct |
5 ms |
256 KB |
Output is correct |
7 |
Correct |
8 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
256 KB |
Output is correct |
2 |
Correct |
11 ms |
384 KB |
Output is correct |
3 |
Correct |
10 ms |
384 KB |
Output is correct |
4 |
Correct |
7 ms |
256 KB |
Output is correct |
5 |
Correct |
7 ms |
256 KB |
Output is correct |
6 |
Correct |
6 ms |
384 KB |
Output is correct |
7 |
Correct |
8 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
17 ms |
384 KB |
Output is correct |
3 |
Correct |
15 ms |
384 KB |
Output is correct |
4 |
Correct |
14 ms |
256 KB |
Output is correct |
5 |
Correct |
8 ms |
256 KB |
Output is correct |
6 |
Correct |
4 ms |
256 KB |
Output is correct |
7 |
Correct |
7 ms |
384 KB |
Output is correct |