Submission #1061824

# Submission time Handle Problem Language Result Execution time Memory
1061824 2024-08-16T14:02:29 Z ArthuroWich Connecting Supertrees (IOI20_supertrees) C++17
11 / 100
126 ms 27876 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 = root+1; j < n; j++) {
            if (vis[j] == co) {
                ans[root][j] = 1;
                ans[j][root] = 1; 
            }
        }
    }
    build(ans);
    return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 440 KB Output is correct
6 Correct 6 ms 1476 KB Output is correct
7 Correct 119 ms 27876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 440 KB Output is correct
6 Correct 6 ms 1476 KB Output is correct
7 Correct 119 ms 27876 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 5 ms 1628 KB Output is correct
13 Correct 126 ms 27740 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 3 ms 960 KB Output is correct
17 Correct 64 ms 18004 KB Output is correct
18 Correct 0 ms 600 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Incorrect 31 ms 7224 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 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Incorrect 0 ms 344 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 440 KB Output is correct
6 Correct 6 ms 1476 KB Output is correct
7 Correct 119 ms 27876 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 5 ms 1628 KB Output is correct
13 Correct 126 ms 27740 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 3 ms 960 KB Output is correct
17 Correct 64 ms 18004 KB Output is correct
18 Correct 0 ms 600 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Incorrect 31 ms 7224 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 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 440 KB Output is correct
6 Correct 6 ms 1476 KB Output is correct
7 Correct 119 ms 27876 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 5 ms 1628 KB Output is correct
13 Correct 126 ms 27740 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 3 ms 960 KB Output is correct
17 Correct 64 ms 18004 KB Output is correct
18 Correct 0 ms 600 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Incorrect 31 ms 7224 KB Too few ways to get from 0 to 5, should be 1 found 0
21 Halted 0 ms 0 KB -