답안 #300822

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
300822 2020-09-17T14:04:54 Z rocks03 슈퍼트리 잇기 (IOI20_supertrees) C++14
21 / 100
260 ms 22264 KB
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define SZ(x) ((int) (x).size())
using namespace std;

void build(vector<vector<int>> _b);

const int MAXN = 1e3+100;
int p[MAXN], sz[MAXN];
void init(int n){
    iota(p, p+n, 0);
    fill(sz, sz+n, 1);
}

int find_parent(int x){
    if(x == p[x])
        return x;
    return p[x] = find_parent(p[x]);
}

bool same_set(int a, int b){
    return (find_parent(a) == find_parent(b));
}

void union_set(int a, int b){
    a = find_parent(a);
    b = find_parent(b);
    if(a == b)
        return;
    if(sz[a] < sz[b])
        swap(a, b);
    p[b] = a;
    sz[a] += sz[b];
}

int construct(vector<vector<int>> p){
    int N = SZ(p);
    init(N);
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(p[i][j] > 0){
                union_set(i, j);
            }
        }
    }
    vector<vector<int>> ans(N, vector<int>(N, 0));
    vector<bool> vis(N, false);
    for(int i = 0; i < N; i++){
        int v = find_parent(i);
        if(!vis[v]){
            vis[v] = true;
            vector<int> vertici;
            vertici.pb(i);
            for(int j = i+1; j < N; j++){
                if(same_set(i, j)){
                    vertici.pb(j);
                }
            }
            for(int j = 1; j < SZ(vertici); j++){
                ans[vertici[j-1]][vertici[j]] = 1;
                ans[vertici[j]][vertici[j-1]] = 1;
            }
            for(int j = 0; j < SZ(vertici); j++){
                for(int k = 0; k < SZ(vertici); k++){
                    if(p[vertici[j]][vertici[k]] == 0)
                        return 0;
                }
            }
        }
    }
    build(ans);
    return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 10 ms 1280 KB Output is correct
7 Correct 252 ms 22264 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 10 ms 1280 KB Output is correct
7 Correct 252 ms 22264 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 10 ms 1184 KB Output is correct
13 Correct 249 ms 22136 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 5 ms 768 KB Output is correct
17 Correct 121 ms 12152 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 0 ms 256 KB Output is correct
20 Correct 61 ms 5880 KB Output is correct
21 Correct 244 ms 22136 KB Output is correct
22 Correct 241 ms 22136 KB Output is correct
23 Correct 253 ms 22136 KB Output is correct
24 Correct 260 ms 22136 KB Output is correct
25 Correct 105 ms 12152 KB Output is correct
26 Correct 101 ms 12152 KB Output is correct
27 Correct 249 ms 22136 KB Output is correct
28 Correct 243 ms 22136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 288 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Incorrect 0 ms 256 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 1 ms 256 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 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 10 ms 1280 KB Output is correct
7 Correct 252 ms 22264 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 10 ms 1184 KB Output is correct
13 Correct 249 ms 22136 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 5 ms 768 KB Output is correct
17 Correct 121 ms 12152 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 0 ms 256 KB Output is correct
20 Correct 61 ms 5880 KB Output is correct
21 Correct 244 ms 22136 KB Output is correct
22 Correct 241 ms 22136 KB Output is correct
23 Correct 253 ms 22136 KB Output is correct
24 Correct 260 ms 22136 KB Output is correct
25 Correct 105 ms 12152 KB Output is correct
26 Correct 101 ms 12152 KB Output is correct
27 Correct 249 ms 22136 KB Output is correct
28 Correct 243 ms 22136 KB Output is correct
29 Correct 0 ms 288 KB Output is correct
30 Correct 0 ms 256 KB Output is correct
31 Correct 0 ms 256 KB Output is correct
32 Incorrect 0 ms 256 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 10 ms 1280 KB Output is correct
7 Correct 252 ms 22264 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 10 ms 1184 KB Output is correct
13 Correct 249 ms 22136 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 5 ms 768 KB Output is correct
17 Correct 121 ms 12152 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 0 ms 256 KB Output is correct
20 Correct 61 ms 5880 KB Output is correct
21 Correct 244 ms 22136 KB Output is correct
22 Correct 241 ms 22136 KB Output is correct
23 Correct 253 ms 22136 KB Output is correct
24 Correct 260 ms 22136 KB Output is correct
25 Correct 105 ms 12152 KB Output is correct
26 Correct 101 ms 12152 KB Output is correct
27 Correct 249 ms 22136 KB Output is correct
28 Correct 243 ms 22136 KB Output is correct
29 Correct 0 ms 288 KB Output is correct
30 Correct 0 ms 256 KB Output is correct
31 Correct 0 ms 256 KB Output is correct
32 Incorrect 0 ms 256 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -