Submission #532538

# Submission time Handle Problem Language Result Execution time Memory
532538 2022-03-03T06:26:16 Z christinelynn Carnival (CEOI14_carnival) C++17
0 / 100
3 ms 296 KB
#include <bits/stdc++.h>
using namespace std;
int N;
int arr[205];
bool check [205];
#define pb push_back
void query(int s,int e,int x){
    vector<int> temp;
    for(int i=s;i<=e;i++){
        temp.pb(i);
    }
    temp.pb(x);
    printf("%d ",temp.size());
    for(auto &i : temp) printf("%d ",i);
    fflush(stdout);
}
int get(int s, int e){
    int count = 0;
    for(int i=s;i<=e;i++){
        if(!check[arr[i]]) count++;
        check[arr[i]] = 1;
    }
    for(int i=s;i<=e;i++){
        check[arr[i]] = 0;
    }
    return count;
}
int main(){
    scanf("%d",&N);
    int color = 1;
    arr[1] = 1;
    for(int i=2;i<=N;i++){
        int temp;
        query(1,i-1,i);
        scanf("%d",&temp);
        if(temp = get(1 ,(i-1) + 1)){
            arr[i] = color++;
            continue;
        }
        for(int j=1;j<i;j++){
            query(j,j,i);
            scanf("%d",&temp);
            if(temp == 1){
                arr[i] = arr[j];
                break;
            }
        }
    }
    printf("0 ");
    for(int i=1;i<=N;i++) printf("%d ",arr[i]);
    return 0;
}

Compilation message

carnival.cpp: In function 'void query(int, int, int)':
carnival.cpp:13:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   13 |     printf("%d ",temp.size());
      |             ~^   ~~~~~~~~~~~
      |              |            |
      |              int          std::vector<int>::size_type {aka long unsigned int}
      |             %ld
carnival.cpp: In function 'int main()':
carnival.cpp:36:17: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   36 |         if(temp = get(1 ,(i-1) + 1)){
      |            ~~~~~^~~~~~~~~~~~~~~~~~~
carnival.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |     scanf("%d",&N);
      |     ~~~~~^~~~~~~~~
carnival.cpp:35:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |         scanf("%d",&temp);
      |         ~~~~~^~~~~~~~~~~~
carnival.cpp:42:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |             scanf("%d",&temp);
      |             ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 200 KB Integer 12 violates the range [1, 11]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 292 KB Integer 6 violates the range [1, 5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 296 KB Integer 2 violates the range [1, 1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 200 KB Integer 5 violates the range [1, 4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 200 KB Integer 3 violates the range [1, 2]
2 Halted 0 ms 0 KB -