답안 #927595

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
927595 2024-02-15T06:55:53 Z haxorman 슈퍼트리 잇기 (IOI20_supertrees) C++14
21 / 100
161 ms 22100 KB
#include <bits/stdc++.h>
#include "supertrees.h"
using namespace std;

const int mxN = 1007;

int dsu[mxN];

int find(int x) {
    return dsu[x] < 0 ? x : dsu[x] = find(dsu[x]);
}

bool unite(int x, int y) {
    x = find(x), y = find(y);

    if (x == y) {
        return false;
    }

    if (dsu[x] > dsu[y]) {
        swap(x, y);
    }
    dsu[x] += dsu[y];
    dsu[y] = x;
    return true;
}

int construct(vector<vector<int>> p) {
	int n = p.size();
    memset(dsu, -1, sizeof(dsu));
    vector<vector<int>> ans(n, vector<int>(n));
    
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (p[i][j]) {
                int x = find(i), y = find(j);
                if (x != y) {
                    ans[x][y] = ans[y][x] = 1;
                    unite(x, y);
                }
            } 
        }
    }
    
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (!p[i][j] && find(i) == find(j)) {
                return 0;
            }
        }
    }

    build(ans);
	return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 6 ms 1112 KB Output is correct
7 Correct 153 ms 22100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 6 ms 1112 KB Output is correct
7 Correct 153 ms 22100 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 6 ms 1116 KB Output is correct
13 Correct 143 ms 22040 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 4 ms 860 KB Output is correct
17 Correct 71 ms 12268 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 37 ms 5712 KB Output is correct
21 Correct 154 ms 22080 KB Output is correct
22 Correct 145 ms 22100 KB Output is correct
23 Correct 160 ms 22100 KB Output is correct
24 Correct 159 ms 22028 KB Output is correct
25 Correct 62 ms 12060 KB Output is correct
26 Correct 60 ms 12112 KB Output is correct
27 Correct 161 ms 22000 KB Output is correct
28 Correct 143 ms 22032 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Too few ways to get from 0 to 1, should be 2 found 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 6 ms 1112 KB Output is correct
7 Correct 153 ms 22100 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 6 ms 1116 KB Output is correct
13 Correct 143 ms 22040 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 4 ms 860 KB Output is correct
17 Correct 71 ms 12268 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 37 ms 5712 KB Output is correct
21 Correct 154 ms 22080 KB Output is correct
22 Correct 145 ms 22100 KB Output is correct
23 Correct 160 ms 22100 KB Output is correct
24 Correct 159 ms 22028 KB Output is correct
25 Correct 62 ms 12060 KB Output is correct
26 Correct 60 ms 12112 KB Output is correct
27 Correct 161 ms 22000 KB Output is correct
28 Correct 143 ms 22032 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Incorrect 0 ms 348 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 6 ms 1112 KB Output is correct
7 Correct 153 ms 22100 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 6 ms 1116 KB Output is correct
13 Correct 143 ms 22040 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 4 ms 860 KB Output is correct
17 Correct 71 ms 12268 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 37 ms 5712 KB Output is correct
21 Correct 154 ms 22080 KB Output is correct
22 Correct 145 ms 22100 KB Output is correct
23 Correct 160 ms 22100 KB Output is correct
24 Correct 159 ms 22028 KB Output is correct
25 Correct 62 ms 12060 KB Output is correct
26 Correct 60 ms 12112 KB Output is correct
27 Correct 161 ms 22000 KB Output is correct
28 Correct 143 ms 22032 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Incorrect 0 ms 348 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -