답안 #574752

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
574752 2022-06-09T11:39:00 Z 1zaid1 사육제 (CEOI14_carnival) C++14
0 / 100
95 ms 336 KB
#include <bits/stdc++.h>
using namespace std;
// #define endl '\n'
const int M = 2e5+5, MOD = 1000000007;
#define int long long
int rnk[M], clr[M], p[M];

int find(int s) {
    return (s == p[s]?s:p[s]=find(p[s]));
}

void uni(int a, int b) {
    if (rnk[a] < rnk[b]) swap(a, b);
    if (rnk[a] == rnk[b]) rnk[a]++;
    p[b] = a;
    clr[a] = min(clr[a], clr[b]);
}

signed main() {
    cin.tie(0)->sync_with_stdio(0);

    int n;
    cin >> n;

    for (int i = 1; i <= n; i++) clr[i] = p[i] = i;

    for (int i=1;i<=n;i++) {
        for(int j=i+1;j<=n;j++) {
            if (find(i) != find(j)) {
                cout << 2 << ' ' << i << ' ' << j << endl;
                int x;
                cin >> x;

                if (x == 1) uni(find(i), find(j));
            }
        }
    }

    cout << 0 << ' ';
    for (int i = 1; i <= n; i++) cout << clr[find(i)] << ' '; cout << endl;

    return 0;
}
/*
3 
0 3 0
3 0 0
5 4 0

3
1 1 1
3 0 1
4 5 1
*/

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:40:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   40 |     for (int i = 1; i <= n; i++) cout << clr[find(i)] << ' '; cout << endl;
      |     ^~~
carnival.cpp:40:63: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   40 |     for (int i = 1; i <= n; i++) cout << clr[find(i)] << ' '; cout << endl;
      |                                                               ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 64 ms 336 KB Integer 19 violates the range [1, 11]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 74 ms 208 KB Integer 6 violates the range [1, 5]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 336 KB Output is correct
2 Incorrect 78 ms 208 KB Integer 11 violates the range [1, 8]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 60 ms 336 KB Integer 5 violates the range [1, 4]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 49 ms 336 KB Partially correct
2 Incorrect 95 ms 336 KB Integer 20 violates the range [1, 17]
3 Halted 0 ms 0 KB -