답안 #532543

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
532543 2022-03-03T06:32:29 Z devariaota 사육제 (CEOI14_carnival) C++17
0 / 100
12 ms 276 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);
    printf("\n");
    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;
}
void bagi(int s,int e,int x){
    if(s == e){
        arr[x] = arr[s];
        return;
    }
    int mid = (s+e)/2;
    query(s,mid,x);
    int temp;
    scanf("%d",&temp);
    if(temp == get(s,mid)) bagi(s,mid,x);
    else bagi(mid+1,e,x);
}
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;
        }
        bagi(1,i-1,i);
    }
    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 'void bagi(int, int, int)':
carnival.cpp:38:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |     scanf("%d",&temp);
      |     ~~~~~^~~~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:43:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |     scanf("%d",&N);
      |     ~~~~~^~~~~~~~~
carnival.cpp:49:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |         scanf("%d",&temp);
      |         ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 200 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 200 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 200 KB Output is correct
2 Incorrect 10 ms 200 KB Incorrect
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 276 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 200 KB Incorrect
2 Halted 0 ms 0 KB -