Submission #119160

# Submission time Handle Problem Language Result Execution time Memory
119160 2019-06-20T14:16:15 Z nvmdava Carnival (CEOI14_carnival) C++17
100 / 100
11 ms 384 KB
#include <bits/stdc++.h>
using namespace std;

int f[155];
int cnt = 1;
int ans[155];

void find(int id, int l, int r){
   if(l == r){
      ans[id] = l;
      return;
   }
   int m = (l + r) >> 1;
   printf("%d ", m - l + 2);
   for(int i = l; i <= m; i++){
      printf("%d ", f[i]);
   }
   printf("%d ", id);
   fflush(stdout);
   int k;
   scanf("%d", &k);
   if(k == m - l + 2){
      find(id, m + 1, r);
   } else find(id, l, m);
}

int main(){
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   int n;
   scanf("%d", &n);
   f[1] = 1;
   ans[1] = 1;
   for(int i = 2; i <= n; i++){
      printf("%d ", i);
      for(int j = 1; j <= i; j++){
         printf("%d ", j);
      }
      fflush(stdout);
      int k;
      scanf("%d", &k);
      if(k == cnt + 1){
         ans[i] = ++cnt;
         f[cnt] = i;
      } else {
         find(i, 1, cnt);
      }
   }
   printf("0 ");
   for(int i = 1; i <= n; i++){
      printf("%d ", ans[i]);
   }
   return 0;
}

Compilation message

carnival.cpp: In function 'void find(int, int, int)':
carnival.cpp:21:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &k);
    ~~~~~^~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:32:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &n);
    ~~~~~^~~~~~~~~~
carnival.cpp:42:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d", &k);
       ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 6 ms 256 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 7 ms 256 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 8 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 3 ms 256 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 8 ms 252 KB Output is correct
7 Correct 9 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 7 ms 256 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 9 ms 256 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 8 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 256 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Correct 3 ms 256 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 8 ms 256 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 256 KB Output is correct
2 Correct 11 ms 256 KB Output is correct
3 Correct 6 ms 256 KB Output is correct
4 Correct 8 ms 384 KB Output is correct
5 Correct 11 ms 256 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 3 ms 256 KB Output is correct