#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef complex<double> cd;
const int MAXN = 1e3+10;
int pai[MAXN], peso[MAXN];
int find(int x){ return (pai[x]==x ? x : pai[x]=find(pai[x])); }
void join(int a, int b){
a=find(a);
b=find(b);
if(a==b) return;
if(peso[a]>peso[b]) swap(a, b);
pai[a]=b;
peso[b]=max(peso[a]+1, peso[b]);
}
vector<int> adj[MAXN];
int construct(vector<vector<int>> p) {
int n = (int)p.size();
vector<vector<int>> ans(n, vector<int>(n, 0));
for(int i=0;i<n;i++) pai[i]=i, peso[i]=0;
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
if(p[i][j]==1 && find(i)!=find(j)){
join(i, j);
adj[i].pb(j);
ans[i][j]=ans[j][i]=1;
}
}
}
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
if(!p[i][j] && find(i)==find(j)){
//~ cout << i << " " << j << "\n";
return 0;
}
}
}
build(ans);
return 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 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 |
4 ms |
1116 KB |
Output is correct |
7 |
Correct |
97 ms |
22080 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 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 |
4 ms |
1116 KB |
Output is correct |
7 |
Correct |
97 ms |
22080 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
4 ms |
1136 KB |
Output is correct |
13 |
Correct |
96 ms |
21972 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
984 KB |
Output is correct |
17 |
Correct |
48 ms |
14244 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
28 ms |
6236 KB |
Output is correct |
21 |
Correct |
97 ms |
24148 KB |
Output is correct |
22 |
Correct |
98 ms |
24008 KB |
Output is correct |
23 |
Correct |
103 ms |
23972 KB |
Output is correct |
24 |
Correct |
93 ms |
24144 KB |
Output is correct |
25 |
Correct |
44 ms |
14248 KB |
Output is correct |
26 |
Correct |
40 ms |
14160 KB |
Output is correct |
27 |
Correct |
130 ms |
24100 KB |
Output is correct |
28 |
Correct |
92 ms |
24148 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Answer gives possible 1 while actual possible 0 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Too few ways to get from 0 to 1, should be 2 found 0 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 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 |
4 ms |
1116 KB |
Output is correct |
7 |
Correct |
97 ms |
22080 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
4 ms |
1136 KB |
Output is correct |
13 |
Correct |
96 ms |
21972 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
984 KB |
Output is correct |
17 |
Correct |
48 ms |
14244 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
28 ms |
6236 KB |
Output is correct |
21 |
Correct |
97 ms |
24148 KB |
Output is correct |
22 |
Correct |
98 ms |
24008 KB |
Output is correct |
23 |
Correct |
103 ms |
23972 KB |
Output is correct |
24 |
Correct |
93 ms |
24144 KB |
Output is correct |
25 |
Correct |
44 ms |
14248 KB |
Output is correct |
26 |
Correct |
40 ms |
14160 KB |
Output is correct |
27 |
Correct |
130 ms |
24100 KB |
Output is correct |
28 |
Correct |
92 ms |
24148 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Incorrect |
0 ms |
348 KB |
Answer gives possible 1 while actual possible 0 |
33 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 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 |
4 ms |
1116 KB |
Output is correct |
7 |
Correct |
97 ms |
22080 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
4 ms |
1136 KB |
Output is correct |
13 |
Correct |
96 ms |
21972 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
984 KB |
Output is correct |
17 |
Correct |
48 ms |
14244 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
28 ms |
6236 KB |
Output is correct |
21 |
Correct |
97 ms |
24148 KB |
Output is correct |
22 |
Correct |
98 ms |
24008 KB |
Output is correct |
23 |
Correct |
103 ms |
23972 KB |
Output is correct |
24 |
Correct |
93 ms |
24144 KB |
Output is correct |
25 |
Correct |
44 ms |
14248 KB |
Output is correct |
26 |
Correct |
40 ms |
14160 KB |
Output is correct |
27 |
Correct |
130 ms |
24100 KB |
Output is correct |
28 |
Correct |
92 ms |
24148 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Incorrect |
0 ms |
348 KB |
Answer gives possible 1 while actual possible 0 |
33 |
Halted |
0 ms |
0 KB |
- |