Submission #29582

# Submission time Handle Problem Language Result Execution time Memory
29582 2017-07-20T07:27:35 Z rondojim Carnival (CEOI14_carnival) C++14
100 / 100
9 ms 1116 KB
#include <stdio.h>
#include <algorithm>
#include <vector>

using namespace std;

const int MAXN = 155;

int color[MAXN], inv[MAXN], N, d, s;

void ask_range(int l, int r){
  printf("%d ", r - l + 1);
  for(int i=l; i<=r; ++i) printf("%d ", i);
  printf("\n");
  fflush(stdout);
  scanf("%d", &s);
}

void ask_color(int idx, int l, int r){
  printf("%d %d ", r - l + 2, idx);
  for(int i=l; i<=r; ++i) printf("%d ", inv[i]);
  printf("\n");
  fflush(stdout);
  scanf("%d", &s);
}

int main(){
  scanf("%d", &N);
  color[1] = d = inv[1] = 1;
  for(int i=2; i<=N; ++i){
    ask_range(1, i);
    if(s == d + 1) inv[color[i] = ++d] = i;
  }
  for(int i=1; i<=N; ++i){
    if(color[i]) continue;
    int lo = 1, hi = d, mid, res;
    while(lo <= hi){
      mid = (lo + hi)>>1;
      ask_color(i, 1, mid);
      if(s == mid) res = mid, hi = mid - 1;
      else lo = mid + 1;
    }
    color[i] = res; 
  }
  printf("0 ");
  for(int i=1; i<=N; ++i) printf("%d ", color[i]);
  return 0;
}

Compilation message

carnival.cpp: In function 'void ask_range(int, int)':
carnival.cpp:16:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &s);
                  ^
carnival.cpp: In function 'void ask_color(int, int, int)':
carnival.cpp:24:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &s);
                  ^
carnival.cpp: In function 'int main()':
carnival.cpp:28:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &N);
                  ^
carnival.cpp:43:19: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
     color[i] = res; 
                   ^
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1116 KB Output is correct
2 Correct 9 ms 1116 KB Output is correct
3 Correct 0 ms 1116 KB Output is correct
4 Correct 0 ms 1116 KB Output is correct
5 Correct 3 ms 1116 KB Output is correct
6 Correct 3 ms 1116 KB Output is correct
7 Correct 3 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1116 KB Output is correct
2 Correct 3 ms 1116 KB Output is correct
3 Correct 6 ms 1116 KB Output is correct
4 Correct 3 ms 1116 KB Output is correct
5 Correct 3 ms 1116 KB Output is correct
6 Correct 6 ms 1116 KB Output is correct
7 Correct 3 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1116 KB Output is correct
2 Correct 3 ms 1116 KB Output is correct
3 Correct 6 ms 1116 KB Output is correct
4 Correct 0 ms 1116 KB Output is correct
5 Correct 6 ms 1116 KB Output is correct
6 Correct 6 ms 1116 KB Output is correct
7 Correct 3 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1116 KB Output is correct
2 Correct 6 ms 1116 KB Output is correct
3 Correct 0 ms 1116 KB Output is correct
4 Correct 3 ms 1116 KB Output is correct
5 Correct 3 ms 1116 KB Output is correct
6 Correct 6 ms 1116 KB Output is correct
7 Correct 0 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1116 KB Output is correct
2 Correct 6 ms 1116 KB Output is correct
3 Correct 9 ms 1116 KB Output is correct
4 Correct 9 ms 1116 KB Output is correct
5 Correct 3 ms 1116 KB Output is correct
6 Correct 3 ms 1116 KB Output is correct
7 Correct 3 ms 1116 KB Output is correct