Submission #1061836

# Submission time Handle Problem Language Result Execution time Memory
1061836 2024-08-16T14:08:20 Z ArthuroWich Connecting Supertrees (IOI20_supertrees) C++17
11 / 100
127 ms 25940 KB
#include "supertrees.h"
#include<bits/stdc++.h>
using namespace std;
vector<vector<int>> adj;
int n, vis[1005], co = 0;
void dfs(int i) {
    if (vis[i]) {
        return;
    }
    vis[i] = co;
    for (int j = 0; j < n; j++) {
        if (i == j || adj[i][j] == 0) {
            continue;
        }
        dfs(j);
    }
}
int construct(vector<vector<int>> p) {
    n = p.size();
    adj = p;
    vector<vector<int>> ans(n, vector<int>(n, 0));
    for (int i = 0; i < n; i++) {
        if (vis[i]) {
            continue;
        }
        co++;
        dfs(i);
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (p[i][j] == 0) {
                if (vis[i] == vis[j]) {
                    return 0;
                }
            } else {
                if (vis[i] != vis[j]) {
                    return 0;
                }
            }
        }
    }
    for (int i = 1; i <= co; i++) {
        int root = 0;
        for (int j = 0; j < n; j++) {
            if (vis[j] == co) {
                root = j;
                break;
            }
        }
        for (int j = 0; j < n; j++) {
            if (j == root) {
                continue;
            }
            if (adj[root][j]) {
                ans[root][j] = 1;
                ans[j][root] = 1;
            }
        }
    }
    build(ans);
    return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 1372 KB Output is correct
7 Correct 111 ms 25940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 1372 KB Output is correct
7 Correct 111 ms 25940 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 5 ms 1372 KB Output is correct
13 Correct 127 ms 25936 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 3 ms 860 KB Output is correct
17 Correct 62 ms 16212 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Incorrect 30 ms 6736 KB Too few ways to get from 0 to 5, should be 1 found 0
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 344 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 0 ms 348 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 1372 KB Output is correct
7 Correct 111 ms 25940 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 5 ms 1372 KB Output is correct
13 Correct 127 ms 25936 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 3 ms 860 KB Output is correct
17 Correct 62 ms 16212 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Incorrect 30 ms 6736 KB Too few ways to get from 0 to 5, should be 1 found 0
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 1372 KB Output is correct
7 Correct 111 ms 25940 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 5 ms 1372 KB Output is correct
13 Correct 127 ms 25936 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 3 ms 860 KB Output is correct
17 Correct 62 ms 16212 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Incorrect 30 ms 6736 KB Too few ways to get from 0 to 5, should be 1 found 0
21 Halted 0 ms 0 KB -