# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1105445 | lkateris | Carnival (CEOI14_carnival) | C++17 | 7 ms | 508 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 <iostream>
#include <vector>
using namespace std;
vector<int> l;
int printq(int a,int b,int n) {
printf("%d",b-a+2);
for(int i = a;i<=b;++i) {
printf(" %d",l[i]);
}
printf(" %d\n",n);
fflush(stdout);
int res = 0;
scanf("%d",&res);
return res;
}
int main()
{
int N;
scanf("%d",&N);
int cost[N+1];
cost[1] = 1;
int cnt = 1;
l.push_back(1);
for(int i=2;i<=N;++i) {
int q = printq(0,cnt-1,i);
if (q > cnt) {
l.push_back(i);
cnt++;
cost[i] = cnt;
}
else {
int l=0;
int r=cnt-1;
int m=(l+r)/2;
while (l < r) {
q = printq(l,m,i);
if (q > m-l+1) l = m+1;
else r = m;
m=(l+r)/2;
}
cost[i] = cost[r+1];
}
}
printf("0");
for(int i=1;i<=N;++i) {
printf(" %d",cost[i]);
}
printf("\n");
fflush(stdout);
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... |