Submission #545140

#TimeUsernameProblemLanguageResultExecution timeMemory
545140rainboyCarnival (CEOI14_carnival)C11
100 / 100
9 ms276 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...