# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
317983 | nandonathaniel | Carnival (CEOI14_carnival) | C++14 | 37 ms | 384 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 ans[155],x;
int tanya(int l,int r){
cout << r-l+1;
for(int i=l;i<=r;i++){
cout << " " << i;
}
cout << endl;
cin >> x;
return x;
}
bool valid(int l,int r){
int y=tanya(l,r);
set<int> S;
for(int i=l;i<r;i++)S.insert(ans[i]);
return S.size()==y;
}
int main(){
int n,x;
cin >> n;
ans[1]=1;
int last=1,no=1;
for(int i=2;i<=n;i++){
int x=tanya(1,i);
if(x>last){
no++;
ans[i]=no;
last=x;
continue;
}
int ki=1,ka=i-1,res;
while(ki<=ka){
int mid=(ki+ka)/2;
if(valid(mid,i)){
res=mid;
ki=mid+1;
}
else ka=mid-1;
}
ans[i]=ans[res];
}
cout << 0;
for(int i=1;i<=n;i++)cout << " " << ans[i];
cout << endl;
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... |