Submission #1105445

#TimeUsernameProblemLanguageResultExecution timeMemory
1105445lkaterisCarnival (CEOI14_carnival)C++17
0 / 100
7 ms508 KiB
#include <iostream> #include <vector> using namespace std; vector<int> l; int printq(int a,int b,int n) { printf("%d",b-a+2); for(int i = a;i<=b;++i) { printf(" %d",l[i]); } printf(" %d\n",n); fflush(stdout); int res = 0; scanf("%d",&res); return res; } int main() { int N; scanf("%d",&N); int cost[N+1]; cost[1] = 1; int cnt = 1; l.push_back(1); for(int i=2;i<=N;++i) { int q = printq(0,cnt-1,i); if (q > cnt) { l.push_back(i); cnt++; cost[i] = cnt; } else { int l=0; int r=cnt-1; int m=(l+r)/2; while (l < r) { q = printq(l,m,i); if (q > m-l+1) l = m+1; else r = m; m=(l+r)/2; } cost[i] = cost[r+1]; } } printf("0"); for(int i=1;i<=N;++i) { printf(" %d",cost[i]); } printf("\n"); fflush(stdout); return 0; }

Compilation message (stderr)

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