답안 #166673

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
166673 2019-12-03T12:50:17 Z wilwxk 사육제 (CEOI14_carnival) C++11
100 / 100
14 ms 428 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

const int MAXN=155;
int rep[MAXN], mp[MAXN];
vector<int> v;
int n, cnt;

void query(int cur, int ini, int fim) {
    // printf("query %d %d %d\n", cur, ini, fim);
    if(fim<ini) return;
    if(ini==fim) {
        printf("2 %d %d\n", cur, v[ini]);
        fflush(stdout);
        int x; scanf("%d", &x);
        if(x==1) rep[cur]=v[ini];
        return;
    }
    int mid=(ini+fim)/2;
    printf("%d %d ", mid-ini+2, cur);
    for(int i=ini; i<=mid; i++) printf("%d ", v[i]);
    printf("\n");
    fflush(stdout);
    int x; scanf("%d", &x);
    if(x>mid-ini+1) ini=mid+1;
    else fim=mid;
    query(cur, ini, fim);
}

int main() {
    scanf("%d", &n);
    for(int i=1; i<=n; i++) rep[i]=i;
    v.push_back(1);
    for(int i=2; i<=n; i++) {
        query(i, 0, v.size()-1);
        if(rep[i]==i) v.push_back(i);
        // printf("%d >> %d\n", i, rep[i]);
    }
    printf("0 ");
    for(int i=1; i<=n; i++) {
        if(!mp[rep[i]]) mp[rep[i]]=++cnt;
        printf("%d ", mp[rep[i]]);
    }
}

Compilation message

carnival.cpp: In function 'void query(int, int, int)':
carnival.cpp:17:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int x; scanf("%d", &x);
                ~~~~~^~~~~~~~~~
carnival.cpp:26:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int x; scanf("%d", &x);
            ~~~~~^~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 252 KB Output is correct
2 Correct 13 ms 248 KB Output is correct
3 Correct 13 ms 376 KB Output is correct
4 Correct 13 ms 376 KB Output is correct
5 Correct 4 ms 376 KB Output is correct
6 Correct 5 ms 248 KB Output is correct
7 Correct 8 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 428 KB Output is correct
2 Correct 11 ms 376 KB Output is correct
3 Correct 10 ms 248 KB Output is correct
4 Correct 12 ms 376 KB Output is correct
5 Correct 9 ms 248 KB Output is correct
6 Correct 8 ms 248 KB Output is correct
7 Correct 9 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 7 ms 248 KB Output is correct
3 Correct 7 ms 248 KB Output is correct
4 Correct 11 ms 296 KB Output is correct
5 Correct 9 ms 296 KB Output is correct
6 Correct 9 ms 376 KB Output is correct
7 Correct 10 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 5 ms 248 KB Output is correct
3 Correct 7 ms 248 KB Output is correct
4 Correct 14 ms 248 KB Output is correct
5 Correct 13 ms 248 KB Output is correct
6 Correct 14 ms 376 KB Output is correct
7 Correct 12 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 11 ms 252 KB Output is correct
3 Correct 7 ms 248 KB Output is correct
4 Correct 11 ms 248 KB Output is correct
5 Correct 11 ms 376 KB Output is correct
6 Correct 14 ms 376 KB Output is correct
7 Correct 7 ms 248 KB Output is correct