Submission #29582

#TimeUsernameProblemLanguageResultExecution timeMemory
29582rondojimCarnival (CEOI14_carnival)C++14
100 / 100
9 ms1116 KiB
#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)

carnival.cpp: In function 'void ask_range(int, int)':
carnival.cpp:16:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &s);
                  ^
carnival.cpp: In function 'void ask_color(int, int, int)':
carnival.cpp:24:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &s);
                  ^
carnival.cpp: In function 'int main()':
carnival.cpp:28:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &N);
                  ^
carnival.cpp:43:19: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
     color[i] = res; 
                   ^
#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...