답안 #807883

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
807883 2023-08-05T04:02:42 Z drdilyor 슈퍼트리 잇기 (IOI20_supertrees) C++17
21 / 100
167 ms 24008 KB
#include<bits/stdc++.h>
#include "supertrees.h"
using namespace std;
using ll = long long;
const int inf = 1e9;

#define debug(args...) cout << "[" << #args << "]: "; debug_out(args...);
void debug_out() {
    cout << endl;
}
template<typename H, typename... T>
void debug_out(H h, T... t) {
    cout << h << ", ";
    debug_out(t...);
}

struct DSU {
    int n;
    vector<int> par;
    DSU(int n) : n(n), par(n) {
        for (int i = 0; i < n; i++)
            par[i] = i;
    }
    void merge(int a, int b) {
        par[get(b)] = get(a);
    }
    int get(int i) {
        return par[i] == i ? i : par[i] = get(par[i]);
    }
};

int construct(std::vector<std::vector<int>> p) {
	int n = p.size();
    DSU cc(n);
    vector ans(n, vector<int>(n));

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (p[i][j]) cc.merge(i, j);
        }
    }
    for (int i = 0; i< n; i++)
        for (int j =0; j < n; j++)
            if (p[i][j] != (cc.get(i) == cc.get(j)))
                return 0;

    vector<vector<int>> full(n);
    for (int i = 0; i < n; i++)
        full[cc.get(i)].push_back(i);
    for (int i = 0; i < n; i++) {
        for (int j = 1; j < (int)full[i].size(); j++) {
            ans[full[i][j]][full[i][j-1]] =
                ans[full[i][j-1]][full[i][j]] = 1;
        }
    }

    build(ans);
	return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 7 ms 1236 KB Output is correct
7 Correct 160 ms 23932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 7 ms 1236 KB Output is correct
7 Correct 160 ms 23932 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 7 ms 1236 KB Output is correct
13 Correct 150 ms 24008 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 4 ms 852 KB Output is correct
17 Correct 83 ms 14072 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 38 ms 6192 KB Output is correct
21 Correct 167 ms 23924 KB Output is correct
22 Correct 151 ms 23920 KB Output is correct
23 Correct 162 ms 23988 KB Output is correct
24 Correct 160 ms 23932 KB Output is correct
25 Correct 59 ms 14080 KB Output is correct
26 Correct 77 ms 14064 KB Output is correct
27 Correct 159 ms 23936 KB Output is correct
28 Correct 151 ms 23992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Answer gives possible 0 while actual possible 1
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Incorrect 1 ms 300 KB Answer gives possible 0 while actual possible 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 7 ms 1236 KB Output is correct
7 Correct 160 ms 23932 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 7 ms 1236 KB Output is correct
13 Correct 150 ms 24008 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 4 ms 852 KB Output is correct
17 Correct 83 ms 14072 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 38 ms 6192 KB Output is correct
21 Correct 167 ms 23924 KB Output is correct
22 Correct 151 ms 23920 KB Output is correct
23 Correct 162 ms 23988 KB Output is correct
24 Correct 160 ms 23932 KB Output is correct
25 Correct 59 ms 14080 KB Output is correct
26 Correct 77 ms 14064 KB Output is correct
27 Correct 159 ms 23936 KB Output is correct
28 Correct 151 ms 23992 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Incorrect 1 ms 212 KB Answer gives possible 0 while actual possible 1
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 7 ms 1236 KB Output is correct
7 Correct 160 ms 23932 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 7 ms 1236 KB Output is correct
13 Correct 150 ms 24008 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 4 ms 852 KB Output is correct
17 Correct 83 ms 14072 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 38 ms 6192 KB Output is correct
21 Correct 167 ms 23924 KB Output is correct
22 Correct 151 ms 23920 KB Output is correct
23 Correct 162 ms 23988 KB Output is correct
24 Correct 160 ms 23932 KB Output is correct
25 Correct 59 ms 14080 KB Output is correct
26 Correct 77 ms 14064 KB Output is correct
27 Correct 159 ms 23936 KB Output is correct
28 Correct 151 ms 23992 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Incorrect 1 ms 212 KB Answer gives possible 0 while actual possible 1
34 Halted 0 ms 0 KB -