답안 #574766

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
574766 2022-06-09T11:46:50 Z 1zaid1 사육제 (CEOI14_carnival) C++14
20 / 100
102 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));
            }
        }
    }

    map<int, int> mp;
    set<int> st;
    for (int i = 1; i <= n; i++) st.insert(find(i));
    int cnt = 1;
    for (int i:st) mp[i] = cnt++;

    cout << 0 << ' ';
    for (int i = 1; i <= n; i++) cout << mp[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:46:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   46 |     for (int i = 1; i <= n; i++) cout << mp[clr[find(i)]] << ' '; cout << endl;
      |     ^~~
carnival.cpp:46:67: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   46 |     for (int i = 1; i <= n; i++) cout << mp[clr[find(i)]] << ' '; cout << endl;
      |                                                                   ^~~~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 63 ms 336 KB Partially correct
2 Partially correct 67 ms 336 KB Partially correct
3 Partially correct 89 ms 336 KB Partially correct
4 Partially correct 100 ms 336 KB Partially correct
5 Partially correct 36 ms 208 KB Partially correct
6 Correct 3 ms 336 KB Output is correct
7 Partially correct 76 ms 208 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 70 ms 208 KB Partially correct
2 Partially correct 37 ms 328 KB Partially correct
3 Partially correct 44 ms 320 KB Partially correct
4 Partially correct 60 ms 336 KB Partially correct
5 Partially correct 48 ms 336 KB Partially correct
6 Correct 19 ms 208 KB Output is correct
7 Partially correct 70 ms 208 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 328 KB Output is correct
2 Partially correct 32 ms 328 KB Partially correct
3 Partially correct 79 ms 336 KB Partially correct
4 Partially correct 80 ms 328 KB Partially correct
5 Partially correct 73 ms 336 KB Partially correct
6 Partially correct 46 ms 336 KB Partially correct
7 Partially correct 87 ms 316 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 54 ms 208 KB Partially correct
2 Partially correct 97 ms 208 KB Partially correct
3 Partially correct 79 ms 336 KB Partially correct
4 Partially correct 102 ms 324 KB Partially correct
5 Partially correct 62 ms 336 KB Partially correct
6 Partially correct 31 ms 328 KB Partially correct
7 Partially correct 77 ms 336 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 52 ms 336 KB Partially correct
2 Partially correct 95 ms 336 KB Partially correct
3 Partially correct 93 ms 336 KB Partially correct
4 Partially correct 86 ms 336 KB Partially correct
5 Partially correct 51 ms 336 KB Partially correct
6 Partially correct 95 ms 316 KB Partially correct
7 Partially correct 72 ms 324 KB Partially correct