#include <bits/stdc++.h>
#define ll long long
using namespace std;
int ask (vector <int> &arr)
{
cout<<arr.size()<<" ";
for (auto i: arr) cout<<i<<" ";
cout<<endl;
int res; cin>>res;
return res;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n; cin>>n;
vector <int> pr, tr;
vector <int> klasa(n);
klasa[0]=1;
int preth=1, maksklasa=1;
pr.push_back(1);
tr.push_back(1);
for (int i=2; i<=n; i++)
{
tr.push_back(i);
if (ask(tr)==preth+1)
{
pr.push_back(i);
maksklasa++;
klasa[i-1]=maksklasa;
preth++;
}
else
{
int ans=-1, l=0, r=pr.size()-1;
while (l<=r)
{
int mid=l+(r-l)/2;
vector <int> pom;
pom.push_back(i); pom.push_back(pr[mid]);
if (ask(pom)==1)
{
ans=pr[mid];
break;
}
vector <int> first, second;
for (int j=l; j<mid; j++)
{
first.push_back(pr[j]);
}
first.push_back(i);
for (int j=mid+1; j<=r; j++)
{
second.push_back(pr[j]);
}
second.push_back(i);
if (ask(first)==first.size())
{
if (first.size()==1)
{
ans=first[0];
}
r=mid-1;
}
else
{
l=mid+1;
}
}
klasa[i-1]=ans;
}
}
cout<<0<<" ";
for (auto i: klasa) cout<<i<<" ";
cout<<endl;
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |