#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
int construct(vector<vector<int>> p) {
int n = p.size();
vector<int> par(n);
vector<vector<int>> ans(n, vector<int>(n));
iota(par.begin(), par.end(), 0);
for (int i = 0; i < n; i++) {
if (par[i] != i) continue;
for (int j = i + 1; j < n; j++) {
if (p[i][j] == 1) {
par[j] = i;
ans[i][j] = ans[j][i] = 1;
}
}
}
vector<int> par2(n);
iota(par2.begin(), par2.end(), 0);
for (int i = 0; i < n; i++) {
if (par[i] != i || par2[i] != i) continue;
int k = i;
for (int j = i + 1; j < n; j++) {
if (par[j] != j || par2[j] != j) continue;
if (p[k][j] == 2) {
par2[j] = i;
ans[k][j] = ans[j][k] = 1;
k = j;
}
}
if (k == i) continue;
ans[k][i] = ans[i][k] = 1;
}
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if (p[i][j] == 0) {
if (par2[par[i]] == par2[par[j]]) {
return 0;
}
} else if (p[i][j] == 1) {
if (par[i] != par[j]) {
return 0;
}
} else if (p[i][j] == 2) {
if (par[i] == par[j] || par2[i] != par2[j]) {
return 0;
}
} else if (p[i][j] == 3) {
return 0;
}
}
}
build(ans);
return 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
436 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
4 ms |
1368 KB |
Output is correct |
7 |
Correct |
108 ms |
23896 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
436 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
4 ms |
1368 KB |
Output is correct |
7 |
Correct |
108 ms |
23896 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
436 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
4 ms |
1372 KB |
Output is correct |
13 |
Correct |
94 ms |
24104 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
860 KB |
Output is correct |
17 |
Correct |
55 ms |
14160 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
27 ms |
6272 KB |
Output is correct |
21 |
Correct |
95 ms |
24068 KB |
Output is correct |
22 |
Correct |
92 ms |
24148 KB |
Output is correct |
23 |
Correct |
126 ms |
23892 KB |
Output is correct |
24 |
Correct |
98 ms |
24144 KB |
Output is correct |
25 |
Correct |
42 ms |
14164 KB |
Output is correct |
26 |
Correct |
41 ms |
14160 KB |
Output is correct |
27 |
Correct |
97 ms |
23944 KB |
Output is correct |
28 |
Correct |
96 ms |
24144 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 |
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 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
24 ms |
6136 KB |
Output is correct |
5 |
Correct |
94 ms |
23944 KB |
Output is correct |
6 |
Correct |
93 ms |
24144 KB |
Output is correct |
7 |
Correct |
133 ms |
24148 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
24 ms |
6140 KB |
Output is correct |
10 |
Correct |
104 ms |
23932 KB |
Output is correct |
11 |
Correct |
102 ms |
23988 KB |
Output is correct |
12 |
Correct |
106 ms |
23936 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
424 KB |
Output is correct |
15 |
Incorrect |
0 ms |
348 KB |
Answer gives possible 0 while actual possible 1 |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
436 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
4 ms |
1368 KB |
Output is correct |
7 |
Correct |
108 ms |
23896 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
436 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
4 ms |
1372 KB |
Output is correct |
13 |
Correct |
94 ms |
24104 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
860 KB |
Output is correct |
17 |
Correct |
55 ms |
14160 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
27 ms |
6272 KB |
Output is correct |
21 |
Correct |
95 ms |
24068 KB |
Output is correct |
22 |
Correct |
92 ms |
24148 KB |
Output is correct |
23 |
Correct |
126 ms |
23892 KB |
Output is correct |
24 |
Correct |
98 ms |
24144 KB |
Output is correct |
25 |
Correct |
42 ms |
14164 KB |
Output is correct |
26 |
Correct |
41 ms |
14160 KB |
Output is correct |
27 |
Correct |
97 ms |
23944 KB |
Output is correct |
28 |
Correct |
96 ms |
24144 KB |
Output is correct |
29 |
Correct |
0 ms |
348 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 |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
436 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
4 ms |
1368 KB |
Output is correct |
7 |
Correct |
108 ms |
23896 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
436 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
4 ms |
1372 KB |
Output is correct |
13 |
Correct |
94 ms |
24104 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
860 KB |
Output is correct |
17 |
Correct |
55 ms |
14160 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
27 ms |
6272 KB |
Output is correct |
21 |
Correct |
95 ms |
24068 KB |
Output is correct |
22 |
Correct |
92 ms |
24148 KB |
Output is correct |
23 |
Correct |
126 ms |
23892 KB |
Output is correct |
24 |
Correct |
98 ms |
24144 KB |
Output is correct |
25 |
Correct |
42 ms |
14164 KB |
Output is correct |
26 |
Correct |
41 ms |
14160 KB |
Output is correct |
27 |
Correct |
97 ms |
23944 KB |
Output is correct |
28 |
Correct |
96 ms |
24144 KB |
Output is correct |
29 |
Correct |
0 ms |
348 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 |
- |