#include "supertrees.h"
#include<bits/stdc++.h>
using namespace std;
#define in insert
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
// #define int long long
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
const int mxn = 1010;
int par[mxn];
int get(int x) {
return (x == par[x] ? x : par[x] = get(par[x]));
}
void unite(int x, int y) {
x = get(x); y = get(y);
if(x == y) return;
par[y] = x;
}
int construct(vector<vector<int>> p) {
int n = p.size();
vector<vector<int>> answer(n, vector<int>(n));
for(int i = 0; i < n; i++) {
par[i] = i;
}
int mx = 0;
for (int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
if(p[i][j] > 0) {
unite(i, j);
mx = max(mx, p[i][j]);
}
}
}
if(mx == 0) {
build(answer);
return 1;
}
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
if(p[i][j] == 0 && get(i) == get(j)) {
return 0;
}
}
}
vector<int> vis(n);
for(int i = 0; i < n; i++) {
if(vis[i]) continue;
int ls = i;
for(int j = i + 1; j < n; j++) {
if(get(j) == get(i)) {
answer[ls][j] = answer[j][ls] = 1;
ls = j;
vis[j] = 1;
}
}
}
build(answer);
return 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
7 ms |
1152 KB |
Output is correct |
7 |
Correct |
152 ms |
22008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
7 ms |
1152 KB |
Output is correct |
7 |
Correct |
152 ms |
22008 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
7 ms |
1268 KB |
Output is correct |
13 |
Correct |
164 ms |
24012 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
3 ms |
852 KB |
Output is correct |
17 |
Correct |
73 ms |
14068 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
40 ms |
6232 KB |
Output is correct |
21 |
Correct |
167 ms |
23996 KB |
Output is correct |
22 |
Correct |
158 ms |
23940 KB |
Output is correct |
23 |
Correct |
161 ms |
23944 KB |
Output is correct |
24 |
Correct |
161 ms |
23944 KB |
Output is correct |
25 |
Correct |
66 ms |
14028 KB |
Output is correct |
26 |
Correct |
75 ms |
14068 KB |
Output is correct |
27 |
Correct |
161 ms |
24072 KB |
Output is correct |
28 |
Correct |
158 ms |
24112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 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 |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Too few ways to get from 0 to 1, should be 2 found 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
7 ms |
1152 KB |
Output is correct |
7 |
Correct |
152 ms |
22008 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
7 ms |
1268 KB |
Output is correct |
13 |
Correct |
164 ms |
24012 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
3 ms |
852 KB |
Output is correct |
17 |
Correct |
73 ms |
14068 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
40 ms |
6232 KB |
Output is correct |
21 |
Correct |
167 ms |
23996 KB |
Output is correct |
22 |
Correct |
158 ms |
23940 KB |
Output is correct |
23 |
Correct |
161 ms |
23944 KB |
Output is correct |
24 |
Correct |
161 ms |
23944 KB |
Output is correct |
25 |
Correct |
66 ms |
14028 KB |
Output is correct |
26 |
Correct |
75 ms |
14068 KB |
Output is correct |
27 |
Correct |
161 ms |
24072 KB |
Output is correct |
28 |
Correct |
158 ms |
24112 KB |
Output is correct |
29 |
Correct |
0 ms |
212 KB |
Output is correct |
30 |
Correct |
0 ms |
212 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Incorrect |
0 ms |
212 KB |
Answer gives possible 1 while actual possible 0 |
33 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
7 ms |
1152 KB |
Output is correct |
7 |
Correct |
152 ms |
22008 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
7 ms |
1268 KB |
Output is correct |
13 |
Correct |
164 ms |
24012 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
3 ms |
852 KB |
Output is correct |
17 |
Correct |
73 ms |
14068 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
40 ms |
6232 KB |
Output is correct |
21 |
Correct |
167 ms |
23996 KB |
Output is correct |
22 |
Correct |
158 ms |
23940 KB |
Output is correct |
23 |
Correct |
161 ms |
23944 KB |
Output is correct |
24 |
Correct |
161 ms |
23944 KB |
Output is correct |
25 |
Correct |
66 ms |
14028 KB |
Output is correct |
26 |
Correct |
75 ms |
14068 KB |
Output is correct |
27 |
Correct |
161 ms |
24072 KB |
Output is correct |
28 |
Correct |
158 ms |
24112 KB |
Output is correct |
29 |
Correct |
0 ms |
212 KB |
Output is correct |
30 |
Correct |
0 ms |
212 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Incorrect |
0 ms |
212 KB |
Answer gives possible 1 while actual possible 0 |
33 |
Halted |
0 ms |
0 KB |
- |