# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
792045 | 2023-07-24T14:19:06 Z | mousebeaver | Connecting Supertrees (IOI20_supertrees) | C++14 | 158 ms | 23980 KB |
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; int construct(vector<vector<int>> p) { bool sub1 = true; bool sub2 = true; int n = p.size(); for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { if(p[i][j] != 1) { sub1 = false; } if(p[i][j] > 1) { sub2 = false; } } } if(sub1) { vector<vector<int>> adjmatrix(n, vector<int> (n, 0)); for(int i = 0; i < n-1; i++) { adjmatrix[i][i+1] = 1; adjmatrix[i+1][i] = 1; } build(adjmatrix); return 1; } if(sub2) { vector<vector<int>> adjmatrix(n, vector<int> (n, 0)); vector<bool> used(n, false); for(int i = 0; i < n; i++) { if(!used[i]) { vector<int> nodes(0); for(int j = 0; j < n; j++) { if(p[i][j] == 1) { nodes.push_back(j); used[j] = true; } } for(int i : nodes) { if(count(p[i].begin(), p[i].end(), 1) != (int) nodes.size()) { return 0; } for(int j : nodes) { if(p[i][j] != 1) { return 0; } } } for(int i = 0; i < (int) nodes.size()-1; i++) { adjmatrix[nodes[i]][nodes[i+1]] = 1; adjmatrix[nodes[i+1]][nodes[i]] = 1; } } } build(adjmatrix); return 1; } //sub3: vector<vector<int>> adjmatrix(n, vector<int> (n, 0)); vector<bool> used(n, false); for(int i = 0; i < n; i++) { if(!used[i]) { vector<int> nodes(0); for(int j = 0; j < n; j++) { if(p[i][j] > 0) { nodes.push_back(j); used[j] = true; } } for(int i : nodes) { if(count(p[i].begin(), p[i].end(), 0) != n-nodes.size()) { return 0; } for(int j : nodes) { if(p[i][j] == 0) { return 0; } } } for(int i = 0; i < (int) nodes.size()-1; i++) { adjmatrix[nodes[i]][nodes[i+1]] = 1; adjmatrix[nodes[i+1]][nodes[i]] = 1; } adjmatrix[nodes[0]][nodes[nodes.size()-1]] = 1; adjmatrix[nodes[nodes.size()-1]][nodes[0]] = 1; } } build(adjmatrix); return 1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 6 ms | 1108 KB | Output is correct |
7 | Correct | 152 ms | 22020 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 6 ms | 1108 KB | Output is correct |
7 | Correct | 152 ms | 22020 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 9 ms | 1108 KB | Output is correct |
13 | Correct | 153 ms | 22000 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 3 ms | 724 KB | Output is correct |
17 | Correct | 67 ms | 12048 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 37 ms | 5768 KB | Output is correct |
21 | Correct | 153 ms | 22092 KB | Output is correct |
22 | Correct | 146 ms | 22016 KB | Output is correct |
23 | Correct | 152 ms | 22032 KB | Output is correct |
24 | Correct | 150 ms | 21964 KB | Output is correct |
25 | Correct | 60 ms | 12048 KB | Output is correct |
26 | Correct | 59 ms | 12036 KB | Output is correct |
27 | Correct | 152 ms | 22016 KB | Output is correct |
28 | Correct | 151 ms | 22016 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Incorrect | 0 ms | 212 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 | 212 KB | Output is correct |
2 | Correct | 1 ms | 224 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 37 ms | 6232 KB | Output is correct |
5 | Correct | 149 ms | 23936 KB | Output is correct |
6 | Correct | 146 ms | 23936 KB | Output is correct |
7 | Correct | 158 ms | 23980 KB | Output is correct |
8 | Incorrect | 1 ms | 212 KB | b[4][4] is not 0 |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 6 ms | 1108 KB | Output is correct |
7 | Correct | 152 ms | 22020 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 9 ms | 1108 KB | Output is correct |
13 | Correct | 153 ms | 22000 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 3 ms | 724 KB | Output is correct |
17 | Correct | 67 ms | 12048 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 37 ms | 5768 KB | Output is correct |
21 | Correct | 153 ms | 22092 KB | Output is correct |
22 | Correct | 146 ms | 22016 KB | Output is correct |
23 | Correct | 152 ms | 22032 KB | Output is correct |
24 | Correct | 150 ms | 21964 KB | Output is correct |
25 | Correct | 60 ms | 12048 KB | Output is correct |
26 | Correct | 59 ms | 12036 KB | Output is correct |
27 | Correct | 152 ms | 22016 KB | Output is correct |
28 | Correct | 151 ms | 22016 KB | Output is correct |
29 | Correct | 0 ms | 212 KB | Output is correct |
30 | Correct | 0 ms | 212 KB | Output is correct |
31 | Correct | 0 ms | 212 KB | Output is correct |
32 | Incorrect | 0 ms | 212 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 | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 6 ms | 1108 KB | Output is correct |
7 | Correct | 152 ms | 22020 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 9 ms | 1108 KB | Output is correct |
13 | Correct | 153 ms | 22000 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 3 ms | 724 KB | Output is correct |
17 | Correct | 67 ms | 12048 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 37 ms | 5768 KB | Output is correct |
21 | Correct | 153 ms | 22092 KB | Output is correct |
22 | Correct | 146 ms | 22016 KB | Output is correct |
23 | Correct | 152 ms | 22032 KB | Output is correct |
24 | Correct | 150 ms | 21964 KB | Output is correct |
25 | Correct | 60 ms | 12048 KB | Output is correct |
26 | Correct | 59 ms | 12036 KB | Output is correct |
27 | Correct | 152 ms | 22016 KB | Output is correct |
28 | Correct | 151 ms | 22016 KB | Output is correct |
29 | Correct | 0 ms | 212 KB | Output is correct |
30 | Correct | 0 ms | 212 KB | Output is correct |
31 | Correct | 0 ms | 212 KB | Output is correct |
32 | Incorrect | 0 ms | 212 KB | Answer gives possible 1 while actual possible 0 |
33 | Halted | 0 ms | 0 KB | - |