#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] > 0) {
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] > 0) {
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] == i) {
root = j;
break;
}
}
for (int j = root+1; j < n; j++) {
if (vis[j] == i) {
ans[root][j] = 1;
ans[j][root] = 1;
}
}
}
build(ans);
return 1;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
388 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
1368 KB |
Output is correct |
7 |
Correct |
113 ms |
25936 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
388 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
1368 KB |
Output is correct |
7 |
Correct |
113 ms |
25936 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
5 ms |
1372 KB |
Output is correct |
13 |
Correct |
111 ms |
25940 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
860 KB |
Output is correct |
17 |
Correct |
63 ms |
16156 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
360 KB |
Output is correct |
20 |
Correct |
31 ms |
6740 KB |
Output is correct |
21 |
Correct |
117 ms |
28044 KB |
Output is correct |
22 |
Correct |
115 ms |
27908 KB |
Output is correct |
23 |
Correct |
122 ms |
28048 KB |
Output is correct |
24 |
Correct |
119 ms |
28084 KB |
Output is correct |
25 |
Correct |
52 ms |
18004 KB |
Output is correct |
26 |
Correct |
51 ms |
18004 KB |
Output is correct |
27 |
Correct |
119 ms |
28044 KB |
Output is correct |
28 |
Correct |
114 ms |
27976 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
Incorrect |
1 ms |
348 KB |
Answer gives possible 1 while actual possible 0 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
388 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
1368 KB |
Output is correct |
7 |
Correct |
113 ms |
25936 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
5 ms |
1372 KB |
Output is correct |
13 |
Correct |
111 ms |
25940 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
860 KB |
Output is correct |
17 |
Correct |
63 ms |
16156 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
360 KB |
Output is correct |
20 |
Correct |
31 ms |
6740 KB |
Output is correct |
21 |
Correct |
117 ms |
28044 KB |
Output is correct |
22 |
Correct |
115 ms |
27908 KB |
Output is correct |
23 |
Correct |
122 ms |
28048 KB |
Output is correct |
24 |
Correct |
119 ms |
28084 KB |
Output is correct |
25 |
Correct |
52 ms |
18004 KB |
Output is correct |
26 |
Correct |
51 ms |
18004 KB |
Output is correct |
27 |
Correct |
119 ms |
28044 KB |
Output is correct |
28 |
Correct |
114 ms |
27976 KB |
Output is correct |
29 |
Correct |
0 ms |
344 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Incorrect |
1 ms |
348 KB |
Answer gives possible 1 while actual possible 0 |
33 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
388 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
1368 KB |
Output is correct |
7 |
Correct |
113 ms |
25936 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
5 ms |
1372 KB |
Output is correct |
13 |
Correct |
111 ms |
25940 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
860 KB |
Output is correct |
17 |
Correct |
63 ms |
16156 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
360 KB |
Output is correct |
20 |
Correct |
31 ms |
6740 KB |
Output is correct |
21 |
Correct |
117 ms |
28044 KB |
Output is correct |
22 |
Correct |
115 ms |
27908 KB |
Output is correct |
23 |
Correct |
122 ms |
28048 KB |
Output is correct |
24 |
Correct |
119 ms |
28084 KB |
Output is correct |
25 |
Correct |
52 ms |
18004 KB |
Output is correct |
26 |
Correct |
51 ms |
18004 KB |
Output is correct |
27 |
Correct |
119 ms |
28044 KB |
Output is correct |
28 |
Correct |
114 ms |
27976 KB |
Output is correct |
29 |
Correct |
0 ms |
344 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Incorrect |
1 ms |
348 KB |
Answer gives possible 1 while actual possible 0 |
33 |
Halted |
0 ms |
0 KB |
- |