답안 #1064998

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1064998 2024-08-18T21:15:04 Z kkkkkkkk 슈퍼트리 잇기 (IOI20_supertrees) C++14
21 / 100
157 ms 24148 KB
#include "supertrees.h"
#include <bits/stdc++.h>

using namespace std;

int parent[1005], sz[1005];

int Find(int x) {
    if (x==parent[x])
        return x;
    return parent[x]=Find(parent[x]);
}

void Union(int a, int b) {
    a=Find(a), b=Find(b);
    if (a==b) return;
    if (sz[a]<sz[b])
        swap(a, b);
    sz[a]+=sz[b];
    parent[b]=a;
}

int construct(vector<vector<int> > paths) {
    int n=paths.size();
    vector<vector<int> > a=paths;
    for (int i=0;i<n;i++)
        sz[i]=1, parent[i]=i;
    for (int i=0;i<n;i++)
        for (int j=0;j<n;j++)
            a[i][j]=0;
    for (int i=0;i<n;i++) {
        for (int j=i+1;j<n;j++) {
            if (paths[i][j]) Union(i, j);
        }
    }
    vector<int> gr[n];
    for (int i=0;i<n;i++) {
        int lider=Find(i);
        gr[lider].push_back(i);
    }
    for (int i=0;i<n;i++) {
        if (gr[i].size()) {
            for (auto x:gr[i])
                for (auto y:gr[i])
                    if (!paths[x][y])
                        return 0;
            int x=gr[i][0];
            for (auto y:gr[i])
                if (x!=y) a[x][y]=1, a[y][x]=1;
        }
    }
    build(a);
    return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 440 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 6 ms 1372 KB Output is correct
7 Correct 128 ms 23960 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 440 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 6 ms 1372 KB Output is correct
7 Correct 128 ms 23960 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 440 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 5 ms 1192 KB Output is correct
13 Correct 111 ms 23952 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 61 ms 14260 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 30 ms 6656 KB Output is correct
21 Correct 124 ms 24144 KB Output is correct
22 Correct 137 ms 24064 KB Output is correct
23 Correct 157 ms 24148 KB Output is correct
24 Correct 114 ms 24148 KB Output is correct
25 Correct 75 ms 14160 KB Output is correct
26 Correct 83 ms 14160 KB Output is correct
27 Correct 125 ms 24148 KB Output is correct
28 Correct 117 ms 23984 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 ms 348 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 544 KB Output is correct
2 Incorrect 1 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 1 ms 348 KB Output is correct
2 Correct 0 ms 440 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 6 ms 1372 KB Output is correct
7 Correct 128 ms 23960 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 440 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 5 ms 1192 KB Output is correct
13 Correct 111 ms 23952 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 61 ms 14260 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 30 ms 6656 KB Output is correct
21 Correct 124 ms 24144 KB Output is correct
22 Correct 137 ms 24064 KB Output is correct
23 Correct 157 ms 24148 KB Output is correct
24 Correct 114 ms 24148 KB Output is correct
25 Correct 75 ms 14160 KB Output is correct
26 Correct 83 ms 14160 KB Output is correct
27 Correct 125 ms 24148 KB Output is correct
28 Correct 117 ms 23984 KB Output is correct
29 Correct 0 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 1 ms 348 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 440 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 6 ms 1372 KB Output is correct
7 Correct 128 ms 23960 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 440 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 5 ms 1192 KB Output is correct
13 Correct 111 ms 23952 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 61 ms 14260 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 30 ms 6656 KB Output is correct
21 Correct 124 ms 24144 KB Output is correct
22 Correct 137 ms 24064 KB Output is correct
23 Correct 157 ms 24148 KB Output is correct
24 Correct 114 ms 24148 KB Output is correct
25 Correct 75 ms 14160 KB Output is correct
26 Correct 83 ms 14160 KB Output is correct
27 Correct 125 ms 24148 KB Output is correct
28 Correct 117 ms 23984 KB Output is correct
29 Correct 0 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 1 ms 348 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -