Submission #951391

# Submission time Handle Problem Language Result Execution time Memory
951391 2024-03-21T22:26:44 Z study Connecting Supertrees (IOI20_supertrees) C++17
21 / 100
179 ms 24136 KB
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;

const int N = 1e3+1;

int comp[N], siz[N];

int getComp(int node){
        if (comp[node] != node) comp[node] = getComp(comp[node]);
        return comp[node];
}

bool merge(int a, int b, bool y){
        a = getComp(a);
        b = getComp(b);
        if (a != b){
                if (!y) return 1;
                if (siz[a] > siz[b]) swap(a,b);
                siz[b] += siz[a];
                comp[a] = b;
                return 1;
        }
        return 0;
}

int construct(vector<vector<int>> p) {
        int n = p.size();
        for (int i=0; i<n; ++i){
                comp[i] = i;
                siz[i] = 1;
        }
        vector<vector<int>> ans(n,vector<int>(n));
        for (int i=0; i<n; ++i){
                for (int j=i+1; j<n; ++j){
                        if (p[i][j] == 1 and merge(i,j,1)){
                                ans[i][j] = 1;
                                ans[j][i] = 1;
                        }
                }
        }
        for (int i=0; i<n; ++i){
                for (int j=i+1; j<n; ++j){
                        if (p[i][j] == 0 and !merge(i,j,0)) return 0;
                }
        }
        build(ans);
        return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 500 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 7 ms 1372 KB Output is correct
7 Correct 179 ms 23944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 500 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 7 ms 1372 KB Output is correct
7 Correct 179 ms 23944 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 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 8 ms 1368 KB Output is correct
13 Correct 151 ms 24036 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 5 ms 856 KB Output is correct
17 Correct 72 ms 14212 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 38 ms 6192 KB Output is correct
21 Correct 161 ms 23896 KB Output is correct
22 Correct 155 ms 23928 KB Output is correct
23 Correct 162 ms 24068 KB Output is correct
24 Correct 156 ms 24136 KB Output is correct
25 Correct 62 ms 14164 KB Output is correct
26 Correct 61 ms 14200 KB Output is correct
27 Correct 156 ms 24080 KB Output is correct
28 Correct 153 ms 24108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 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 -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 344 KB Too few ways to get from 0 to 1, should be 2 found 0
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 500 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 7 ms 1372 KB Output is correct
7 Correct 179 ms 23944 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 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 8 ms 1368 KB Output is correct
13 Correct 151 ms 24036 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 5 ms 856 KB Output is correct
17 Correct 72 ms 14212 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 38 ms 6192 KB Output is correct
21 Correct 161 ms 23896 KB Output is correct
22 Correct 155 ms 23928 KB Output is correct
23 Correct 162 ms 24068 KB Output is correct
24 Correct 156 ms 24136 KB Output is correct
25 Correct 62 ms 14164 KB Output is correct
26 Correct 61 ms 14200 KB Output is correct
27 Correct 156 ms 24080 KB Output is correct
28 Correct 153 ms 24108 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 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 -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 500 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 7 ms 1372 KB Output is correct
7 Correct 179 ms 23944 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 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 8 ms 1368 KB Output is correct
13 Correct 151 ms 24036 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 5 ms 856 KB Output is correct
17 Correct 72 ms 14212 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 38 ms 6192 KB Output is correct
21 Correct 161 ms 23896 KB Output is correct
22 Correct 155 ms 23928 KB Output is correct
23 Correct 162 ms 24068 KB Output is correct
24 Correct 156 ms 24136 KB Output is correct
25 Correct 62 ms 14164 KB Output is correct
26 Correct 61 ms 14200 KB Output is correct
27 Correct 156 ms 24080 KB Output is correct
28 Correct 153 ms 24108 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 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 -