#include "supertrees.h"
#include <vector>
#include <cassert>
using namespace std;
int construct(vector<vector<int>> p) {
int n = p.size();
vector<vector<int>> res (n);
vector<bool> inc (n);
for (int i = 0; i < n; ++i) {
if (!res[i].empty()) continue;
res[i].assign(n, 0);
inc[i] = true;
for (int j = 0; j < n; ++j) {
if (p[i][j] == 0 || i == j) continue;
if (p[i][j] == 1){
res[j].assign(n, 0);
res[j][i] = 1;
res[i][j] = 1;
}
}
}
for (int i = 0; i < n; ++i) {
if (!inc[i]) continue;
int ft = -1, lt = -1, bt = -1, at = -1;
for (int j = 0; j < n; ++j) {
if (p[i][j] == 2 && inc[j]){
if (ft == -1) ft = j;
if (j < i) bt = j;
if (j > i && at == -1) at = j;
lt = j;
}
}
if (lt == -1) continue;
if (at == -1) at = ft;
if (bt == -1) bt = lt;
res[i][bt] = 1;
res[i][at] = 1;
}
build(res);
return 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
284 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
288 KB |
Output is correct |
5 |
Correct |
1 ms |
288 KB |
Output is correct |
6 |
Correct |
9 ms |
1164 KB |
Output is correct |
7 |
Correct |
141 ms |
22716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
284 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
288 KB |
Output is correct |
5 |
Correct |
1 ms |
288 KB |
Output is correct |
6 |
Correct |
9 ms |
1164 KB |
Output is correct |
7 |
Correct |
141 ms |
22716 KB |
Output is correct |
8 |
Correct |
0 ms |
284 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
284 KB |
Output is correct |
12 |
Correct |
9 ms |
1260 KB |
Output is correct |
13 |
Correct |
150 ms |
22728 KB |
Output is correct |
14 |
Incorrect |
0 ms |
212 KB |
Answer gives possible 1 while actual possible 0 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
288 KB |
Output is correct |
3 |
Correct |
1 ms |
288 KB |
Output is correct |
4 |
Incorrect |
1 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 |
0 ms |
284 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
38 ms |
6032 KB |
Output is correct |
5 |
Correct |
144 ms |
22408 KB |
Output is correct |
6 |
Correct |
139 ms |
22352 KB |
Output is correct |
7 |
Correct |
141 ms |
22392 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
39 ms |
6004 KB |
Output is correct |
10 |
Correct |
150 ms |
23964 KB |
Output is correct |
11 |
Correct |
142 ms |
23916 KB |
Output is correct |
12 |
Correct |
145 ms |
23916 KB |
Output is correct |
13 |
Correct |
1 ms |
280 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
38 ms |
6156 KB |
Output is correct |
17 |
Correct |
151 ms |
23920 KB |
Output is correct |
18 |
Correct |
161 ms |
23920 KB |
Output is correct |
19 |
Correct |
139 ms |
23976 KB |
Output is correct |
20 |
Correct |
148 ms |
23884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
284 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
288 KB |
Output is correct |
5 |
Correct |
1 ms |
288 KB |
Output is correct |
6 |
Correct |
9 ms |
1164 KB |
Output is correct |
7 |
Correct |
141 ms |
22716 KB |
Output is correct |
8 |
Correct |
0 ms |
284 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
284 KB |
Output is correct |
12 |
Correct |
9 ms |
1260 KB |
Output is correct |
13 |
Correct |
150 ms |
22728 KB |
Output is correct |
14 |
Incorrect |
0 ms |
212 KB |
Answer gives possible 1 while actual possible 0 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
284 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
288 KB |
Output is correct |
5 |
Correct |
1 ms |
288 KB |
Output is correct |
6 |
Correct |
9 ms |
1164 KB |
Output is correct |
7 |
Correct |
141 ms |
22716 KB |
Output is correct |
8 |
Correct |
0 ms |
284 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
284 KB |
Output is correct |
12 |
Correct |
9 ms |
1260 KB |
Output is correct |
13 |
Correct |
150 ms |
22728 KB |
Output is correct |
14 |
Incorrect |
0 ms |
212 KB |
Answer gives possible 1 while actual possible 0 |
15 |
Halted |
0 ms |
0 KB |
- |