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;
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;
}
# | 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... |