# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
46196 | ikura355 | Carnival (CEOI14_carnival) | C++14 | 15 ms | 576 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;
const int maxn = 150 + 5;
int n;
int c, rep[maxn], com[maxn];
vector<int> p, act;
int ask() {
printf("%d",act.size());
for(auto x : act) printf(" %d",x);
printf("\n");
fflush(stdout);
int ret; scanf("%d",&ret);
return ret;
}
int noey(int l, int r, int x) {
act.clear();
for(int i=l;i<=r;i++) act.push_back(p[i]);
int old = ask();
act.push_back(x);
int boy = ask();
return old == boy;
}
void connect(int x) {
p.clear();
for(int i=1;i<=c;i++) p.push_back(rep[i]);
//1. new component
if(c==0 || !noey(0,p.size()-1,x)) {
rep[++c] = x;
com[x] = c;
return ;
}
//2. connecting
int l = 0, r = p.size()-1;
while(l<r) {
int mid = (l+r)/2;
if(noey(l,mid,x)) r = mid;
else l = mid+1;
}
com[x] = com[p[l]];
}
int main() {
scanf("%d",&n);
for(int x=1;x<=n;x++) connect(x);
printf("0");
for(int x=1;x<=n;x++) printf(" %d",com[x]);
fflush(stdout);
}
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... |