#include <stdio.h>
#include <string.h>
#define N 150
int query(int *ii, int k) {
int h, x;
printf("%d", k);
for (h = 0; h < k; h++)
printf(" %d", ii[h] + 1);
printf("\n"), fflush(stdout);
scanf("%d", &x);
return x;
}
int main() {
static int ii[N], ii_[N], hh[N];
int n, n_, i;
scanf("%d", &n);
n_ = 0;
for (i = 0; i < n; i++) {
ii[n_] = i;
if (query(ii, n_ + 1) == n_ + 1)
hh[i] = n_++;
else {
int lower = 0, upper = n_;
while (upper - lower > 1) {
int h = (lower + upper) / 2;
memcpy(ii_, ii + lower, (h - lower) * sizeof *ii);
ii_[h - lower] = i;
if (query(ii_, h - lower + 1) == h - lower + 1)
lower = h;
else
upper = h;
}
hh[i] = lower;
}
}
printf("0");
for (i = 0; i < n; i++)
printf(" %d", hh[i] + 1);
printf("\n");
return 0;
}
Compilation message
carnival.c: In function 'query':
carnival.c:13:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
13 | scanf("%d", &x);
| ^~~~~~~~~~~~~~~
carnival.c: In function 'main':
carnival.c:21:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
21 | scanf("%d", &n);
| ^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
208 KB |
Output is correct |
2 |
Correct |
6 ms |
208 KB |
Output is correct |
3 |
Correct |
4 ms |
208 KB |
Output is correct |
4 |
Correct |
3 ms |
208 KB |
Output is correct |
5 |
Correct |
4 ms |
208 KB |
Output is correct |
6 |
Correct |
2 ms |
208 KB |
Output is correct |
7 |
Correct |
6 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
208 KB |
Output is correct |
2 |
Correct |
9 ms |
208 KB |
Output is correct |
3 |
Correct |
3 ms |
208 KB |
Output is correct |
4 |
Correct |
4 ms |
208 KB |
Output is correct |
5 |
Correct |
5 ms |
208 KB |
Output is correct |
6 |
Correct |
5 ms |
208 KB |
Output is correct |
7 |
Correct |
5 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
5 ms |
208 KB |
Output is correct |
3 |
Correct |
6 ms |
208 KB |
Output is correct |
4 |
Correct |
3 ms |
208 KB |
Output is correct |
5 |
Correct |
5 ms |
208 KB |
Output is correct |
6 |
Correct |
4 ms |
208 KB |
Output is correct |
7 |
Correct |
6 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
208 KB |
Output is correct |
2 |
Correct |
5 ms |
208 KB |
Output is correct |
3 |
Correct |
3 ms |
208 KB |
Output is correct |
4 |
Correct |
2 ms |
208 KB |
Output is correct |
5 |
Correct |
5 ms |
208 KB |
Output is correct |
6 |
Correct |
5 ms |
208 KB |
Output is correct |
7 |
Correct |
8 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
208 KB |
Output is correct |
2 |
Correct |
6 ms |
208 KB |
Output is correct |
3 |
Correct |
9 ms |
208 KB |
Output is correct |
4 |
Correct |
6 ms |
208 KB |
Output is correct |
5 |
Correct |
7 ms |
208 KB |
Output is correct |
6 |
Correct |
3 ms |
276 KB |
Output is correct |
7 |
Correct |
3 ms |
208 KB |
Output is correct |