Submission #119156

# Submission time Handle Problem Language Result Execution time Memory
119156 2019-06-20T14:12:25 Z nvmdava Carnival (CEOI14_carnival) C++17
0 / 100
8 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;
   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:41: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 Incorrect 6 ms 256 KB Integer 0 violates the range [1, 11]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 384 KB Integer 0 violates the range [1, 5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Integer 0 violates the range [1, 1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 256 KB Integer 0 violates the range [1, 4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Integer 0 violates the range [1, 2]
2 Halted 0 ms 0 KB -