Submission #667359

#TimeUsernameProblemLanguageResultExecution timeMemory
667359RambaXGorillaCarnival (CEOI14_carnival)C++17
100 / 100
16 ms276 KiB
#include<cstdio> using namespace std; int N; int costs[610]; int vis[155] = {}; int cnt = 1; int party(int l, int r, int x = 0){ printf("%d ",r - l + 1 + (bool) x); if(x) printf("%d ",x); for(int i = l;i < r + 1;i++){ printf("%d ",i); } fflush(stdout); int y; scanf("%d",&y); return y; } void fillCosts(int v = 1, int tl = 1, int tr = N){ if(tl == tr) return; costs[v] = party(tl, tr); int tm = (tl + tr) / 2; fillCosts(v * 2, tl, tm); fillCosts(v * 2 + 1, tm + 1, tr); } void travCosts(int x, int v = 1, int tl = 1, int tr = N){ if(tr <= x){ return; } if(tl == tr){ if(party(tl, tl, x) == 1) vis[tl] = cnt; return; } if(tl > x && party(tl, tr, x) != costs[v]) return; int tm = (tl + tr) / 2; travCosts(x, v * 2, tl, tm); travCosts(x, v * 2 + 1, tm + 1, tr); } int main(){ scanf("%d",&N); fillCosts(); for(int i = 1;i < N + 1;i++){ if(!vis[i]){ vis[i] = cnt; travCosts(i); cnt++; } } printf("0 "); for(int i = 1;i < N + 1;i++){ printf("%d ",vis[i]); } }

Compilation message (stderr)

carnival.cpp: In function 'int party(int, int, int)':
carnival.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%d",&y);
      |     ~~~~~^~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:39:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |     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...