# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
29582 | rondojim | Carnival (CEOI14_carnival) | C++14 | 9 ms | 1116 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 <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;
const int MAXN = 155;
int color[MAXN], inv[MAXN], N, d, s;
void ask_range(int l, int r){
printf("%d ", r - l + 1);
for(int i=l; i<=r; ++i) printf("%d ", i);
printf("\n");
fflush(stdout);
scanf("%d", &s);
}
void ask_color(int idx, int l, int r){
printf("%d %d ", r - l + 2, idx);
for(int i=l; i<=r; ++i) printf("%d ", inv[i]);
printf("\n");
fflush(stdout);
scanf("%d", &s);
}
int main(){
scanf("%d", &N);
color[1] = d = inv[1] = 1;
for(int i=2; i<=N; ++i){
ask_range(1, i);
if(s == d + 1) inv[color[i] = ++d] = i;
}
for(int i=1; i<=N; ++i){
if(color[i]) continue;
int lo = 1, hi = d, mid, res;
while(lo <= hi){
mid = (lo + hi)>>1;
ask_color(i, 1, mid);
if(s == mid) res = mid, hi = mid - 1;
else lo = mid + 1;
}
color[i] = res;
}
printf("0 ");
for(int i=1; i<=N; ++i) printf("%d ", color[i]);
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... |