#include <bits/stdc++.h>
using namespace std;
const int nx=155;
int n, ans[nx], res, cnt;
int query(vector<int> v)
{
if (v.size()==1) return 1;
cout<<v.size()<<' ';
for (auto x:v) cout<<x<<' ';
cout<<endl;
cin>>res;
return res;
}
int in(int idx, int l, int r)
{
if (r<l) return 0;
vector<int> qrs;
for (int i=l; i<=r; i++) qrs.push_back(i);
auto sv=query(qrs);
qrs.push_back(idx);
auto nw=query(qrs);
return sv==nw;
}
int search(int idx, int l, int r)
{
if (l==r) return l;
int md=(l+r)/2;
if (in(idx, l, md)) return search(idx, l, md);
else return search(idx, md+1, r);
}
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n;
for (int i=1; i<=n; i++)
{
if (!in(i, i+1, n))
{
if (ans[i]==0) ans[i]=++cnt;
}
else
{
int vl=search(i, i+1, n);
if (!ans[i]) ans[i]=++cnt, ans[vl]=ans[i];
else ans[vl]=ans[i];
}
}
cout<<0<<' ';
for (int i=1; i<=n; i++) cout<<ans[i]<<' ';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
712 KB |
Output is correct |
2 |
Correct |
8 ms |
460 KB |
Output is correct |
3 |
Correct |
4 ms |
708 KB |
Output is correct |
4 |
Correct |
3 ms |
456 KB |
Output is correct |
5 |
Correct |
9 ms |
708 KB |
Output is correct |
6 |
Correct |
9 ms |
712 KB |
Output is correct |
7 |
Correct |
8 ms |
460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
456 KB |
Output is correct |
2 |
Correct |
8 ms |
712 KB |
Output is correct |
3 |
Correct |
5 ms |
444 KB |
Output is correct |
4 |
Correct |
4 ms |
456 KB |
Output is correct |
5 |
Correct |
9 ms |
468 KB |
Output is correct |
6 |
Correct |
10 ms |
720 KB |
Output is correct |
7 |
Correct |
9 ms |
708 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
460 KB |
Output is correct |
2 |
Correct |
9 ms |
712 KB |
Output is correct |
3 |
Correct |
7 ms |
708 KB |
Output is correct |
4 |
Correct |
3 ms |
708 KB |
Output is correct |
5 |
Correct |
9 ms |
712 KB |
Output is correct |
6 |
Correct |
9 ms |
460 KB |
Output is correct |
7 |
Correct |
9 ms |
712 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
456 KB |
Output is correct |
2 |
Correct |
11 ms |
708 KB |
Output is correct |
3 |
Correct |
4 ms |
460 KB |
Output is correct |
4 |
Correct |
3 ms |
460 KB |
Output is correct |
5 |
Correct |
7 ms |
712 KB |
Output is correct |
6 |
Correct |
8 ms |
460 KB |
Output is correct |
7 |
Correct |
9 ms |
712 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
452 KB |
Output is correct |
2 |
Correct |
11 ms |
452 KB |
Output is correct |
3 |
Correct |
7 ms |
712 KB |
Output is correct |
4 |
Correct |
5 ms |
460 KB |
Output is correct |
5 |
Correct |
7 ms |
712 KB |
Output is correct |
6 |
Correct |
5 ms |
712 KB |
Output is correct |
7 |
Correct |
3 ms |
452 KB |
Output is correct |