Submission #26171

# Submission time Handle Problem Language Result Execution time Memory
26171 2017-06-28T08:00:38 Z ruhanhabib39 Carnival (CEOI14_carnival) C++14
100 / 100
16 ms 2020 KB
#include <bits/stdc++.h>
using namespace std;

int N;

vector<int> gp;
int res[150 + 10];

int query(vector<int> v) {
   printf("%d", (int)v.size());
   for(int i : v) {
      printf(" %d", i);
   }
   printf("\n"); fflush(stdout);
   int k; scanf("%d", &k);
   return k;
}

int main() {
   scanf("%d", &N);
   gp.push_back(1);
   for(int i = 2; i <= N; i++) {
      gp.push_back(i);
      if(query(gp) != gp.size()) {
         gp.pop_back();
      }
   }
   for(int i = 0; i < (int)gp.size(); i++) {
      res[gp[i]] = i+1;
   }
   for(int i = 1; i <= N; i++) {
      if(res[i]) continue;
      int lo = 1, hi = gp.size();
      while(lo < hi) {
         int m = (lo + hi) / 2;
         auto q = vector<int>(gp.begin(), gp.begin() + m);
         q.push_back(i);
         if(query(q) < q.size()) hi = m;
         else lo = m+1;
      }
      res[i] = lo;
   }
   printf("0");
   for(int i = 1; i <= N; i++) {
      printf(" %d", res[i]);
   }
   printf("\n"); fflush(stdout);
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:24:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       if(query(gp) != gp.size()) {
                    ^
carnival.cpp:38:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
          if(query(q) < q.size()) hi = m;
                      ^
carnival.cpp: In function 'int query(std::vector<int>)':
carnival.cpp:15:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    int k; scanf("%d", &k);
                          ^
carnival.cpp: In function 'int main()':
carnival.cpp:20:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &N);
                   ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 0 ms 2020 KB Output is correct
3 Correct 0 ms 2020 KB Output is correct
4 Correct 3 ms 2020 KB Output is correct
5 Correct 0 ms 2020 KB Output is correct
6 Correct 0 ms 2020 KB Output is correct
7 Correct 3 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2020 KB Output is correct
2 Correct 0 ms 2020 KB Output is correct
3 Correct 3 ms 2020 KB Output is correct
4 Correct 3 ms 2020 KB Output is correct
5 Correct 3 ms 2020 KB Output is correct
6 Correct 3 ms 2020 KB Output is correct
7 Correct 16 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 0 ms 2020 KB Output is correct
3 Correct 3 ms 2020 KB Output is correct
4 Correct 3 ms 2020 KB Output is correct
5 Correct 0 ms 2020 KB Output is correct
6 Correct 3 ms 2020 KB Output is correct
7 Correct 9 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 0 ms 2020 KB Output is correct
3 Correct 0 ms 2020 KB Output is correct
4 Correct 3 ms 2020 KB Output is correct
5 Correct 0 ms 2020 KB Output is correct
6 Correct 6 ms 2020 KB Output is correct
7 Correct 9 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 3 ms 2020 KB Output is correct
3 Correct 0 ms 2020 KB Output is correct
4 Correct 3 ms 2020 KB Output is correct
5 Correct 0 ms 2020 KB Output is correct
6 Correct 6 ms 2020 KB Output is correct
7 Correct 3 ms 2020 KB Output is correct