답안 #47428

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
47428 2018-05-02T22:22:05 Z TAMREF 사육제 (CEOI14_carnival) C++11
20 / 100
102 ms 584 KB
#include <bits/stdc++.h>
using namespace std;

const int mx = 155;

int rep[mx];
int n;

int f(int x){return x == rep[x] ? x : rep[x] = f(rep[x]);}
void c(int x, int y){
    x = f(x), y = f(y);
    rep[y] = x;
}

void init(){
    cin >> n;
    iota(rep+1,rep+n+1,1);
}
void naive(){
    int q;
    for(int i = 1; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            if(f(i) != f(j)){
                cout << 2 << ' ';
                cout << f(i) << ' ' << f(j) << endl;
                cin >> q;
                if(q == 1) c(i,j);
            }
        }
    }

    map<int,int> M;
    for(int i = 1; i <= n; i++){
        if(!M[f(i)]){
            M[f(i)] = -1;
            M[f(i)] = M.size();
        }
    }
    cout << 0;
    for(int i = 1; i <= n; i++){
        cout << ' ' << M[f(i)];
    }
    cout << endl;
}

int main(){
    init();
    naive();
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 64 ms 248 KB Partially correct
2 Partially correct 67 ms 308 KB Partially correct
3 Partially correct 71 ms 448 KB Partially correct
4 Partially correct 75 ms 528 KB Partially correct
5 Partially correct 41 ms 544 KB Partially correct
6 Correct 4 ms 544 KB Output is correct
7 Partially correct 71 ms 544 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 51 ms 544 KB Partially correct
2 Partially correct 81 ms 544 KB Partially correct
3 Partially correct 23 ms 544 KB Partially correct
4 Partially correct 102 ms 544 KB Partially correct
5 Partially correct 48 ms 544 KB Partially correct
6 Correct 22 ms 544 KB Output is correct
7 Partially correct 55 ms 544 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 544 KB Output is correct
2 Partially correct 71 ms 544 KB Partially correct
3 Partially correct 38 ms 560 KB Partially correct
4 Partially correct 86 ms 564 KB Partially correct
5 Partially correct 47 ms 564 KB Partially correct
6 Partially correct 34 ms 564 KB Partially correct
7 Partially correct 88 ms 568 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 62 ms 568 KB Partially correct
2 Partially correct 73 ms 580 KB Partially correct
3 Partially correct 60 ms 584 KB Partially correct
4 Partially correct 95 ms 584 KB Partially correct
5 Partially correct 69 ms 584 KB Partially correct
6 Partially correct 64 ms 584 KB Partially correct
7 Partially correct 58 ms 584 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 45 ms 584 KB Partially correct
2 Partially correct 90 ms 584 KB Partially correct
3 Partially correct 89 ms 584 KB Partially correct
4 Partially correct 85 ms 584 KB Partially correct
5 Partially correct 64 ms 584 KB Partially correct
6 Partially correct 82 ms 584 KB Partially correct
7 Partially correct 65 ms 584 KB Partially correct