#include <bits/stdc++.h>
#include "supertrees.h"
using namespace std;
#define pb push_back
const int N=1050;
vector<int> E[N];
void AddEdge(int u,int v){E[u].pb(v),E[v].pb(u);}
bool was[N];
vector<int> comp;
void DFS(int u){
was[u]=true,comp.push_back(u);
for(int v:E[u])if(!was[v])DFS(v);
}
int construct(vector<vector<int>> p){
int n=(int)p.size();
for(int i=0;i<n;i++)for(int j=0;j<n;j++)if(p[i][j]==3)return 0;
for(int i=0;i<n;i++)for(int j=i;j<n;j++)if(p[i][j]>0)AddEdge(i,j);
vector<vector<int>> ans(n,vector<int>(n,0));
bool two=false;
for(int i=0;i<n;i++)for(int j=0;j<n;j++)if(p[i][j]==2)two=true;
for(int i=0;i<n;i++){
if(!was[i]){
DFS(i);
if(two&&(int)comp.size()==2)return 0;
for(int x:comp)for(int y:comp)if(x!=y&&p[x][y]==0)return 0;
for(int i=1;i<(int)comp.size();i++){
int x=comp[i],y=comp[i-1];
ans[x][y]=ans[y][x]=1;
}
if((int)comp.size()>=3){
int x=comp[0],y=comp.back();
ans[x][y]=ans[y][x]=1;
}
comp.clear();
}
}
build(ans);
return 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Incorrect |
1 ms |
364 KB |
Too many ways to get from 0 to 2, should be 1 found no less than 2 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Incorrect |
1 ms |
364 KB |
Too many ways to get from 0 to 2, should be 1 found no less than 2 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
10 ms |
1260 KB |
Output is correct |
9 |
Correct |
257 ms |
23788 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
12 ms |
1516 KB |
Output is correct |
13 |
Correct |
266 ms |
27856 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
5 ms |
1004 KB |
Output is correct |
17 |
Correct |
122 ms |
16772 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
64 ms |
6380 KB |
Output is correct |
22 |
Correct |
257 ms |
24300 KB |
Output is correct |
23 |
Correct |
268 ms |
23752 KB |
Output is correct |
24 |
Correct |
285 ms |
26860 KB |
Output is correct |
25 |
Correct |
112 ms |
13804 KB |
Output is correct |
26 |
Correct |
122 ms |
14316 KB |
Output is correct |
27 |
Correct |
267 ms |
23788 KB |
Output is correct |
28 |
Correct |
280 ms |
25964 KB |
Output is correct |
29 |
Correct |
110 ms |
13804 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Incorrect |
1 ms |
364 KB |
Too many ways to get from 1 to 4, should be 1 found no less than 2 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Incorrect |
1 ms |
364 KB |
Too many ways to get from 0 to 2, should be 1 found no less than 2 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Incorrect |
1 ms |
364 KB |
Too many ways to get from 0 to 2, should be 1 found no less than 2 |
4 |
Halted |
0 ms |
0 KB |
- |