#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
vector<long>parent;
std::vector<std::vector<int> > answer;
long find_set(long x)
{
if(parent[x]==x){
return x;
}
long z=find_set(parent[x]);
parent[x]=z;
return z;
}
void union_set(long x,long z)
{
x=find_set(x);
z=find_set(z);
if(x!=z){
parent[z]=x;
answer[x][z]=1;
answer[z][x]=1;
}
}
int construct(std::vector<std::vector<int> > p) {
int n = p.size();
for(long i=0;i<n;i++){
parent.push_back(i);
}
for (int i = 0; i < n; i++) {
std::vector<int> row;
row.resize(n);
answer.push_back(row);
}
bool ok=true;
for(long i=0;i<n;i++){
for(long j=i+1;j<n;j++){
if(p[i][j]==1){
union_set(i,j);
}
}
}
for(long i=0;i<n;i++){
for(long j=i+1;j<n;j++){
if(p[i][j]==0){
if(find_set(i)==find_set(j)){
ok=false;
i=n;
break;
}
}
}
}
if(ok){
build(answer);
return 1;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
11 ms |
1388 KB |
Output is correct |
7 |
Correct |
250 ms |
22120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
11 ms |
1388 KB |
Output is correct |
7 |
Correct |
250 ms |
22120 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
396 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
11 ms |
1260 KB |
Output is correct |
13 |
Correct |
257 ms |
22244 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
748 KB |
Output is correct |
17 |
Correct |
116 ms |
12164 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
66 ms |
5860 KB |
Output is correct |
21 |
Correct |
258 ms |
22116 KB |
Output is correct |
22 |
Correct |
254 ms |
22116 KB |
Output is correct |
23 |
Correct |
268 ms |
22148 KB |
Output is correct |
24 |
Correct |
272 ms |
22116 KB |
Output is correct |
25 |
Correct |
109 ms |
12264 KB |
Output is correct |
26 |
Correct |
104 ms |
12132 KB |
Output is correct |
27 |
Correct |
280 ms |
22112 KB |
Output is correct |
28 |
Correct |
257 ms |
22176 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Incorrect |
1 ms |
364 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 |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Too few ways to get from 0 to 1, should be 2 found 0 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
11 ms |
1388 KB |
Output is correct |
7 |
Correct |
250 ms |
22120 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
396 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
11 ms |
1260 KB |
Output is correct |
13 |
Correct |
257 ms |
22244 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
748 KB |
Output is correct |
17 |
Correct |
116 ms |
12164 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
66 ms |
5860 KB |
Output is correct |
21 |
Correct |
258 ms |
22116 KB |
Output is correct |
22 |
Correct |
254 ms |
22116 KB |
Output is correct |
23 |
Correct |
268 ms |
22148 KB |
Output is correct |
24 |
Correct |
272 ms |
22116 KB |
Output is correct |
25 |
Correct |
109 ms |
12264 KB |
Output is correct |
26 |
Correct |
104 ms |
12132 KB |
Output is correct |
27 |
Correct |
280 ms |
22112 KB |
Output is correct |
28 |
Correct |
257 ms |
22176 KB |
Output is correct |
29 |
Correct |
1 ms |
364 KB |
Output is correct |
30 |
Correct |
1 ms |
364 KB |
Output is correct |
31 |
Correct |
1 ms |
364 KB |
Output is correct |
32 |
Incorrect |
1 ms |
364 KB |
Answer gives possible 1 while actual possible 0 |
33 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
11 ms |
1388 KB |
Output is correct |
7 |
Correct |
250 ms |
22120 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
396 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
11 ms |
1260 KB |
Output is correct |
13 |
Correct |
257 ms |
22244 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
748 KB |
Output is correct |
17 |
Correct |
116 ms |
12164 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
66 ms |
5860 KB |
Output is correct |
21 |
Correct |
258 ms |
22116 KB |
Output is correct |
22 |
Correct |
254 ms |
22116 KB |
Output is correct |
23 |
Correct |
268 ms |
22148 KB |
Output is correct |
24 |
Correct |
272 ms |
22116 KB |
Output is correct |
25 |
Correct |
109 ms |
12264 KB |
Output is correct |
26 |
Correct |
104 ms |
12132 KB |
Output is correct |
27 |
Correct |
280 ms |
22112 KB |
Output is correct |
28 |
Correct |
257 ms |
22176 KB |
Output is correct |
29 |
Correct |
1 ms |
364 KB |
Output is correct |
30 |
Correct |
1 ms |
364 KB |
Output is correct |
31 |
Correct |
1 ms |
364 KB |
Output is correct |
32 |
Incorrect |
1 ms |
364 KB |
Answer gives possible 1 while actual possible 0 |
33 |
Halted |
0 ms |
0 KB |
- |