#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
int construct(vector<vector<int>> p) {
int N = p.size();
vector<int> group(N,-1);
bool vis[N]{};
vector<vector<int>> answer(N);
for(int i = 0; i < N; i++) {
answer[i].assign(N,0);
}
for (int i = 0; i < N; i++) {
if(!vis[i]) {
vis[i] = true;
group[i] = i;
for(int j = 0; j < N; j++) {
if(i != j && p[i][j]) {
if(vis[j]) return 0;
vis[j] = true;
answer[i][j] = answer[j][i] = 1;
group[j] = i;
}
}
}
}
/*for(int i = 0; i < connectedGroups.size(); i++) {
cout << i << ":\n";
for(auto x: connectedGroups[i])
cout << x << endl;
}*/
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if((i != j) && ((group[i] == group[j]) != (p[i][j]))) {
return 0;
}
}
}
build(answer);
return 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
10 ms |
1100 KB |
Output is correct |
7 |
Correct |
224 ms |
22084 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
10 ms |
1100 KB |
Output is correct |
7 |
Correct |
224 ms |
22084 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
10 ms |
1100 KB |
Output is correct |
13 |
Correct |
226 ms |
22268 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
5 ms |
788 KB |
Output is correct |
17 |
Correct |
102 ms |
14060 KB |
Output is correct |
18 |
Correct |
1 ms |
292 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
59 ms |
6212 KB |
Output is correct |
21 |
Correct |
230 ms |
24004 KB |
Output is correct |
22 |
Correct |
231 ms |
24004 KB |
Output is correct |
23 |
Correct |
239 ms |
23932 KB |
Output is correct |
24 |
Correct |
238 ms |
23924 KB |
Output is correct |
25 |
Correct |
97 ms |
14020 KB |
Output is correct |
26 |
Correct |
92 ms |
14080 KB |
Output is correct |
27 |
Correct |
257 ms |
23920 KB |
Output is correct |
28 |
Correct |
244 ms |
23932 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Incorrect |
1 ms |
204 KB |
Answer gives possible 0 while actual possible 1 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Answer gives possible 0 while actual possible 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
10 ms |
1100 KB |
Output is correct |
7 |
Correct |
224 ms |
22084 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
10 ms |
1100 KB |
Output is correct |
13 |
Correct |
226 ms |
22268 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
5 ms |
788 KB |
Output is correct |
17 |
Correct |
102 ms |
14060 KB |
Output is correct |
18 |
Correct |
1 ms |
292 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
59 ms |
6212 KB |
Output is correct |
21 |
Correct |
230 ms |
24004 KB |
Output is correct |
22 |
Correct |
231 ms |
24004 KB |
Output is correct |
23 |
Correct |
239 ms |
23932 KB |
Output is correct |
24 |
Correct |
238 ms |
23924 KB |
Output is correct |
25 |
Correct |
97 ms |
14020 KB |
Output is correct |
26 |
Correct |
92 ms |
14080 KB |
Output is correct |
27 |
Correct |
257 ms |
23920 KB |
Output is correct |
28 |
Correct |
244 ms |
23932 KB |
Output is correct |
29 |
Correct |
1 ms |
204 KB |
Output is correct |
30 |
Correct |
1 ms |
204 KB |
Output is correct |
31 |
Correct |
1 ms |
204 KB |
Output is correct |
32 |
Correct |
1 ms |
204 KB |
Output is correct |
33 |
Incorrect |
1 ms |
204 KB |
Answer gives possible 0 while actual possible 1 |
34 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
10 ms |
1100 KB |
Output is correct |
7 |
Correct |
224 ms |
22084 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
10 ms |
1100 KB |
Output is correct |
13 |
Correct |
226 ms |
22268 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
5 ms |
788 KB |
Output is correct |
17 |
Correct |
102 ms |
14060 KB |
Output is correct |
18 |
Correct |
1 ms |
292 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
59 ms |
6212 KB |
Output is correct |
21 |
Correct |
230 ms |
24004 KB |
Output is correct |
22 |
Correct |
231 ms |
24004 KB |
Output is correct |
23 |
Correct |
239 ms |
23932 KB |
Output is correct |
24 |
Correct |
238 ms |
23924 KB |
Output is correct |
25 |
Correct |
97 ms |
14020 KB |
Output is correct |
26 |
Correct |
92 ms |
14080 KB |
Output is correct |
27 |
Correct |
257 ms |
23920 KB |
Output is correct |
28 |
Correct |
244 ms |
23932 KB |
Output is correct |
29 |
Correct |
1 ms |
204 KB |
Output is correct |
30 |
Correct |
1 ms |
204 KB |
Output is correct |
31 |
Correct |
1 ms |
204 KB |
Output is correct |
32 |
Correct |
1 ms |
204 KB |
Output is correct |
33 |
Incorrect |
1 ms |
204 KB |
Answer gives possible 0 while actual possible 1 |
34 |
Halted |
0 ms |
0 KB |
- |