# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
985892 | simona1230 | Carnival (CEOI14_carnival) | C++17 | 4 ms | 716 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int n,num;
int in[256];
int a[256];
int guess(vector<int> v)
{
cout<<v.size()<<" ";
for(int i=0;i<v.size();i++)
cout<<v[i]<<" ";
cout<<endl;
cout.flush();
int val;
cin>>val;
return val;
}
void solve()
{
for(int i=1;i<=n;i++)
{
in[i]=1;
vector<int> v;
for(int j=1;j<=i;j++)
if(in[j])v.push_back(j);
int x=guess(v);
if(x>num)
{
num++;
a[i]=num;
continue;
}
in[i]=0;
vector<int> h;
int ans=0;
int l=0,r=v.size()-2;
while(l<=r)
{
if(l==r)
{
ans=v[l];
break;
}
int m=(l+r)/2;
h.clear();
for(int j=l;j<=m;j++)
h.push_back(v[j]);
h.push_back(i);
x=guess(h);
if(x==m-l+1)
{
r=m;
}
else
{
l=m+1;
}
}
a[i]=a[ans];
}
cout<<"0 ";
for(int i=1;i<=n;i++)
cout<<a[i]<<" ";
cout<<endl;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n;
solve();
return 0;
}
Compilation message (stderr)
# | 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... |