Submission #166541

# Submission time Handle Problem Language Result Execution time Memory
166541 2019-12-02T17:52:09 Z wilwxk Carnival (CEOI14_carnival) C++14
20 / 100
124 ms 376 KB
#include <bits/stdc++.h>
using namespace std;

const int MAXN=155;
int rep[MAXN], repp[MAXN];
int mp[MAXN];
int n, cnt;

int find(int x) {
    return rep[x]= rep[x]==x ? x : find(rep[x]);
}
void une(int a, int b) {
    a=find(a); b=find(b);
    if(a==b) return;
    if(repp[a]>repp[b]) swap(a, b);
    rep[a]=b;
}

int main() {
    scanf("%d", &n);
    for(int i=1; i<=n; i++) rep[i]=repp[i]=i;
    for(int i=1; i<=n; i++) {
        for(int j=1; j<i; j++) {
            printf("2 %d %d\n", i, j);
            fflush(stdout);
            int x; scanf("%d", &x);
            if(x==1) une(i, j);
        }
    }

    printf("0 ");
    for(int i=1; i<=n; i++) {
        if(!mp[find(i)]) mp[find(i)]=++cnt;
        printf("%d ", mp[find(i)]);
    }
    fflush(stdout);
    return 0;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
carnival.cpp:26:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             int x; scanf("%d", &x);
                    ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Partially correct 56 ms 248 KB Partially correct
2 Partially correct 93 ms 292 KB Partially correct
3 Partially correct 97 ms 248 KB Partially correct
4 Partially correct 80 ms 376 KB Partially correct
5 Partially correct 91 ms 248 KB Partially correct
6 Partially correct 52 ms 376 KB Partially correct
7 Partially correct 66 ms 248 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 51 ms 376 KB Partially correct
2 Partially correct 97 ms 376 KB Partially correct
3 Partially correct 58 ms 248 KB Partially correct
4 Partially correct 60 ms 376 KB Partially correct
5 Partially correct 114 ms 376 KB Partially correct
6 Partially correct 114 ms 248 KB Partially correct
7 Partially correct 106 ms 376 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 77 ms 376 KB Partially correct
2 Partially correct 94 ms 248 KB Partially correct
3 Partially correct 97 ms 248 KB Partially correct
4 Partially correct 52 ms 248 KB Partially correct
5 Partially correct 78 ms 248 KB Partially correct
6 Partially correct 57 ms 376 KB Partially correct
7 Partially correct 108 ms 248 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 121 ms 248 KB Partially correct
2 Partially correct 99 ms 248 KB Partially correct
3 Partially correct 79 ms 376 KB Partially correct
4 Partially correct 106 ms 248 KB Partially correct
5 Partially correct 52 ms 248 KB Partially correct
6 Partially correct 65 ms 248 KB Partially correct
7 Partially correct 99 ms 376 KB Partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 102 ms 252 KB Partially correct
2 Partially correct 109 ms 248 KB Partially correct
3 Partially correct 124 ms 252 KB Partially correct
4 Partially correct 100 ms 252 KB Partially correct
5 Partially correct 101 ms 248 KB Partially correct
6 Partially correct 98 ms 248 KB Partially correct
7 Partially correct 59 ms 248 KB Partially correct