#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
const int N=1e3+110;
vector<int> g1[N];
vector<int> g2[N];
int vis[N];
int vis2[N];
vector<vector<int>> answer;
vector<int> vec;
int construct(vector<vector<int>> p){
int n = p.size();
vector<int> tmp(n);
for(int i=0;i<n;i++){
answer.push_back(tmp);
}
for(int i=0;i<n;i++){
g1[i].push_back(i);
g2[i].push_back(i);
for(int j=i;j<n;j++){
int v=p[i][j];
if(v==3||(i==j&&v!=1)||p[i][j]!=p[j][i]){
return 0;
}
if(v==2){
g2[i].push_back(j);
g2[j].push_back(i);
}
if(v==1&&i!=j){
g1[i].push_back(j);
g1[j].push_back(i);
}
}
}
for(int i=0;i<n;i++){
sort(g1[i].begin(),g1[i].end());
sort(g2[i].begin(),g2[i].end());
}
int cnt=0;
for(int i=0;i<n;i++){
if(vis[i]==0){
cnt++;
int sz=g1[i].size();
vis[g1[i][0]]=cnt;
for(int j=0;j<sz-1;j++){
vis[g1[i][j]]=cnt;
vis[g1[i][j+1]]=cnt;
answer[g1[i][j]][g1[i][j+1]]=1;
answer[g1[i][j+1]][g1[i][j]]=1;
if(g1[g1[i][j]]!=g1[g1[i][j+1]])return 0;
}
}
}
//memset(vis,0,sizeof(vis));
for(int i=0;i<n;i++){
if(vis2[vis[i]]==0){
vis2[vis[g2[i][0]]]=1;
int sz=g2[i].size();
int lst=g2[i][0];
for(int j=0;j<sz-1;j++){
// if(g2[g2[i][j]]!=g2[g2[i][j+1]])return 0;
}
for(int j=1;j<sz;j++){
if(vis2[vis[g2[i][j]]]==0){
vis2[vis[g2[i][j]]]=1;
answer[lst][g2[i][j]]=1;
// cout<<lst<<" "<<g2[i][j]<<endl;
answer[g2[i][j]][lst]=1;
lst=g2[i][j];
}
}
// cout<<lst<<" "<<g2[i][0]<<endl;
answer[lst][g2[i][0]]=1;
answer[g2[i][0]][lst]=1;
}
}
/*
for(int i=0;i<n;i++)cout<<vis[i]<<" ";cout<<endl;
for(int i=0;i<n;i++){
cout<<i<<" : ";
for(auto y:g1[i]){
cout<<y<<" ";
}
cout<<endl;
}
for(int i=0;i<n;i++){
cout<<i<<" : ";
for(auto y:g2[i]){
cout<<y<<" ";
}
cout<<endl;
}
*/
for(int i=0;i<n;i++){
answer[i][i]=0;
}
build(answer);
return 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
9 ms |
1356 KB |
Output is correct |
7 |
Correct |
246 ms |
26160 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
9 ms |
1356 KB |
Output is correct |
7 |
Correct |
246 ms |
26160 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
0 ms |
332 KB |
Output is correct |
11 |
Correct |
0 ms |
332 KB |
Output is correct |
12 |
Correct |
7 ms |
1152 KB |
Output is correct |
13 |
Correct |
205 ms |
22068 KB |
Output is correct |
14 |
Correct |
0 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
3 ms |
972 KB |
Output is correct |
17 |
Correct |
84 ms |
15024 KB |
Output is correct |
18 |
Correct |
0 ms |
332 KB |
Output is correct |
19 |
Correct |
0 ms |
332 KB |
Output is correct |
20 |
Correct |
44 ms |
5812 KB |
Output is correct |
21 |
Correct |
228 ms |
22588 KB |
Output is correct |
22 |
Correct |
173 ms |
22076 KB |
Output is correct |
23 |
Correct |
198 ms |
24180 KB |
Output is correct |
24 |
Correct |
196 ms |
22072 KB |
Output is correct |
25 |
Correct |
70 ms |
12732 KB |
Output is correct |
26 |
Correct |
64 ms |
12208 KB |
Output is correct |
27 |
Correct |
211 ms |
25180 KB |
Output is correct |
28 |
Correct |
168 ms |
22084 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Incorrect |
0 ms |
332 KB |
Answer gives possible 1 while actual possible 0 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
49 ms |
5876 KB |
Output is correct |
5 |
Correct |
184 ms |
22628 KB |
Output is correct |
6 |
Correct |
176 ms |
22048 KB |
Output is correct |
7 |
Correct |
196 ms |
24132 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
43 ms |
5812 KB |
Output is correct |
10 |
Correct |
171 ms |
22548 KB |
Output is correct |
11 |
Correct |
170 ms |
22340 KB |
Output is correct |
12 |
Correct |
182 ms |
25144 KB |
Output is correct |
13 |
Correct |
0 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
44 ms |
5840 KB |
Output is correct |
17 |
Correct |
182 ms |
22580 KB |
Output is correct |
18 |
Correct |
180 ms |
22716 KB |
Output is correct |
19 |
Correct |
175 ms |
22252 KB |
Output is correct |
20 |
Correct |
170 ms |
22292 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
9 ms |
1356 KB |
Output is correct |
7 |
Correct |
246 ms |
26160 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
0 ms |
332 KB |
Output is correct |
11 |
Correct |
0 ms |
332 KB |
Output is correct |
12 |
Correct |
7 ms |
1152 KB |
Output is correct |
13 |
Correct |
205 ms |
22068 KB |
Output is correct |
14 |
Correct |
0 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
3 ms |
972 KB |
Output is correct |
17 |
Correct |
84 ms |
15024 KB |
Output is correct |
18 |
Correct |
0 ms |
332 KB |
Output is correct |
19 |
Correct |
0 ms |
332 KB |
Output is correct |
20 |
Correct |
44 ms |
5812 KB |
Output is correct |
21 |
Correct |
228 ms |
22588 KB |
Output is correct |
22 |
Correct |
173 ms |
22076 KB |
Output is correct |
23 |
Correct |
198 ms |
24180 KB |
Output is correct |
24 |
Correct |
196 ms |
22072 KB |
Output is correct |
25 |
Correct |
70 ms |
12732 KB |
Output is correct |
26 |
Correct |
64 ms |
12208 KB |
Output is correct |
27 |
Correct |
211 ms |
25180 KB |
Output is correct |
28 |
Correct |
168 ms |
22084 KB |
Output is correct |
29 |
Correct |
1 ms |
332 KB |
Output is correct |
30 |
Correct |
1 ms |
332 KB |
Output is correct |
31 |
Correct |
0 ms |
332 KB |
Output is correct |
32 |
Incorrect |
0 ms |
332 KB |
Answer gives possible 1 while actual possible 0 |
33 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
9 ms |
1356 KB |
Output is correct |
7 |
Correct |
246 ms |
26160 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
0 ms |
332 KB |
Output is correct |
11 |
Correct |
0 ms |
332 KB |
Output is correct |
12 |
Correct |
7 ms |
1152 KB |
Output is correct |
13 |
Correct |
205 ms |
22068 KB |
Output is correct |
14 |
Correct |
0 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
3 ms |
972 KB |
Output is correct |
17 |
Correct |
84 ms |
15024 KB |
Output is correct |
18 |
Correct |
0 ms |
332 KB |
Output is correct |
19 |
Correct |
0 ms |
332 KB |
Output is correct |
20 |
Correct |
44 ms |
5812 KB |
Output is correct |
21 |
Correct |
228 ms |
22588 KB |
Output is correct |
22 |
Correct |
173 ms |
22076 KB |
Output is correct |
23 |
Correct |
198 ms |
24180 KB |
Output is correct |
24 |
Correct |
196 ms |
22072 KB |
Output is correct |
25 |
Correct |
70 ms |
12732 KB |
Output is correct |
26 |
Correct |
64 ms |
12208 KB |
Output is correct |
27 |
Correct |
211 ms |
25180 KB |
Output is correct |
28 |
Correct |
168 ms |
22084 KB |
Output is correct |
29 |
Correct |
1 ms |
332 KB |
Output is correct |
30 |
Correct |
1 ms |
332 KB |
Output is correct |
31 |
Correct |
0 ms |
332 KB |
Output is correct |
32 |
Incorrect |
0 ms |
332 KB |
Answer gives possible 1 while actual possible 0 |
33 |
Halted |
0 ms |
0 KB |
- |