#include "supertrees.h"
#include<bits/stdc++.h>
using namespace std;
const int N=1e3+10;
int pa[N];
bool cy[N][N];
int root(int x){
if(pa[x]==x) return x;
else return pa[x]=root(pa[x]);
}
int construct(vector<vector<int> > p) {
int n = p.size();
vector<vector<int> > answer;
for (int i = 0; i < n; i++) {
vector<int> row(n,0);
answer.push_back(row);
}
for(int i=0;i<n;i++) pa[i]=i;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(p[i][j]==1 && root(i)!=root(j)){
answer[i][j]=1;
answer[j][i]=1;
pa[root(i)]=root(j);
}
if(p[i][j]==3) return 0;
}
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(p[i][j]==0){
if(root(i)==root(j)) return 0;
}
}
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
int a,b;
if(p[i][j]==2){
a=root(i),b=root(j);
if(a==b) return 0;
if(cy[a][b]) continue;
answer[a][b]=1;
answer[b][a]=1;
cy[a][b]=1,cy[b][a]=1;
}
}
}
build(answer);
return 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
1116 KB |
Output is correct |
7 |
Correct |
125 ms |
22044 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
1116 KB |
Output is correct |
7 |
Correct |
125 ms |
22044 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
5 ms |
1116 KB |
Output is correct |
13 |
Correct |
116 ms |
22100 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
860 KB |
Output is correct |
17 |
Correct |
79 ms |
12048 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
30 ms |
5724 KB |
Output is correct |
21 |
Correct |
122 ms |
22156 KB |
Output is correct |
22 |
Correct |
125 ms |
22356 KB |
Output is correct |
23 |
Correct |
144 ms |
22032 KB |
Output is correct |
24 |
Correct |
124 ms |
22044 KB |
Output is correct |
25 |
Correct |
51 ms |
12056 KB |
Output is correct |
26 |
Correct |
51 ms |
12372 KB |
Output is correct |
27 |
Correct |
139 ms |
22032 KB |
Output is correct |
28 |
Correct |
125 ms |
22100 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 |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
408 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 |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
62 ms |
5792 KB |
Output is correct |
5 |
Correct |
122 ms |
22100 KB |
Output is correct |
6 |
Correct |
115 ms |
22096 KB |
Output is correct |
7 |
Correct |
128 ms |
22100 KB |
Output is correct |
8 |
Incorrect |
0 ms |
348 KB |
Too many ways to get from 0 to 2, should be 2 found no less than 3 |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
1116 KB |
Output is correct |
7 |
Correct |
125 ms |
22044 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
5 ms |
1116 KB |
Output is correct |
13 |
Correct |
116 ms |
22100 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
860 KB |
Output is correct |
17 |
Correct |
79 ms |
12048 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
30 ms |
5724 KB |
Output is correct |
21 |
Correct |
122 ms |
22156 KB |
Output is correct |
22 |
Correct |
125 ms |
22356 KB |
Output is correct |
23 |
Correct |
144 ms |
22032 KB |
Output is correct |
24 |
Correct |
124 ms |
22044 KB |
Output is correct |
25 |
Correct |
51 ms |
12056 KB |
Output is correct |
26 |
Correct |
51 ms |
12372 KB |
Output is correct |
27 |
Correct |
139 ms |
22032 KB |
Output is correct |
28 |
Correct |
125 ms |
22100 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
1 ms |
348 KB |
Output is correct |
32 |
Incorrect |
0 ms |
408 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 |
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 |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
1116 KB |
Output is correct |
7 |
Correct |
125 ms |
22044 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
5 ms |
1116 KB |
Output is correct |
13 |
Correct |
116 ms |
22100 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
860 KB |
Output is correct |
17 |
Correct |
79 ms |
12048 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
30 ms |
5724 KB |
Output is correct |
21 |
Correct |
122 ms |
22156 KB |
Output is correct |
22 |
Correct |
125 ms |
22356 KB |
Output is correct |
23 |
Correct |
144 ms |
22032 KB |
Output is correct |
24 |
Correct |
124 ms |
22044 KB |
Output is correct |
25 |
Correct |
51 ms |
12056 KB |
Output is correct |
26 |
Correct |
51 ms |
12372 KB |
Output is correct |
27 |
Correct |
139 ms |
22032 KB |
Output is correct |
28 |
Correct |
125 ms |
22100 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
1 ms |
348 KB |
Output is correct |
32 |
Incorrect |
0 ms |
408 KB |
Answer gives possible 1 while actual possible 0 |
33 |
Halted |
0 ms |
0 KB |
- |