Submission #1007440

# Submission time Handle Problem Language Result Execution time Memory
1007440 2024-06-24T23:38:35 Z u_suck_o Connecting Supertrees (IOI20_supertrees) C++17
21 / 100
116 ms 22104 KB
#include "supertrees.h"
#include "bits/stdc++.h"
#define MAXN 1005

using namespace std;

int N;
int sizes[MAXN], par[MAXN];
vector<vector<int>> answer;

int find(int u) {
    if (u != par[u])
        par[u] = find(par[u]);
    return par[u];
}

void join(int u, int v) {
    u = find(u);
    v = find(v);
    if (u == v) return;
    answer[u][v] = 1;
    answer[v][u] = 1;
    if (sizes[u] > sizes[v]) {
        par[v] = u;
        sizes[u] += sizes[v];
    } else {
        par[u] = v;
        sizes[v] += sizes[u];
    }
}

int construct(vector<vector<int>> p) {
    N = p.size();
    answer = vector<vector<int>>(N, vector<int>(N, 0));
    
    for (int i = 0; i < N; i++) {
        par[i] = i;
        sizes[i] = 1;
    }
    
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            if (p[i][j])
                join(i, j);
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (p[i][j] && find(i) != find(j))
                return 0;
            if (!p[i][j] && find(i) == find(j))
                return 0;
        }
    }
    build(answer);
    return 1;
}
# Verdict Execution time Memory 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 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 5 ms 1116 KB Output is correct
7 Correct 106 ms 22040 KB Output is correct
# Verdict Execution time Memory 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 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 5 ms 1116 KB Output is correct
7 Correct 106 ms 22040 KB Output is correct
8 Correct 0 ms 600 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 344 KB Output is correct
12 Correct 5 ms 1116 KB Output is correct
13 Correct 110 ms 22044 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 2 ms 860 KB Output is correct
17 Correct 56 ms 12060 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 28 ms 5908 KB Output is correct
21 Correct 111 ms 22100 KB Output is correct
22 Correct 110 ms 22104 KB Output is correct
23 Correct 116 ms 22100 KB Output is correct
24 Correct 102 ms 22048 KB Output is correct
25 Correct 46 ms 12116 KB Output is correct
26 Correct 48 ms 12112 KB Output is correct
27 Correct 110 ms 22036 KB Output is correct
28 Correct 113 ms 22100 KB Output is correct
# Verdict Execution time Memory 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 0 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 348 KB Too few ways to get from 0 to 1, should be 2 found 1
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 5 ms 1116 KB Output is correct
7 Correct 106 ms 22040 KB Output is correct
8 Correct 0 ms 600 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 344 KB Output is correct
12 Correct 5 ms 1116 KB Output is correct
13 Correct 110 ms 22044 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 2 ms 860 KB Output is correct
17 Correct 56 ms 12060 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 28 ms 5908 KB Output is correct
21 Correct 111 ms 22100 KB Output is correct
22 Correct 110 ms 22104 KB Output is correct
23 Correct 116 ms 22100 KB Output is correct
24 Correct 102 ms 22048 KB Output is correct
25 Correct 46 ms 12116 KB Output is correct
26 Correct 48 ms 12112 KB Output is correct
27 Correct 110 ms 22036 KB Output is correct
28 Correct 113 ms 22100 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 0 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 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 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 5 ms 1116 KB Output is correct
7 Correct 106 ms 22040 KB Output is correct
8 Correct 0 ms 600 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 344 KB Output is correct
12 Correct 5 ms 1116 KB Output is correct
13 Correct 110 ms 22044 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 2 ms 860 KB Output is correct
17 Correct 56 ms 12060 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 28 ms 5908 KB Output is correct
21 Correct 111 ms 22100 KB Output is correct
22 Correct 110 ms 22104 KB Output is correct
23 Correct 116 ms 22100 KB Output is correct
24 Correct 102 ms 22048 KB Output is correct
25 Correct 46 ms 12116 KB Output is correct
26 Correct 48 ms 12112 KB Output is correct
27 Correct 110 ms 22036 KB Output is correct
28 Correct 113 ms 22100 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 0 ms 348 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -