#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 20;
int cnt[maxn][maxn];
vector<vector<int>> res;
bool flag[maxn];
int n;
void add_edge(int u, int v) {
res[u][v] = true;
res[v][u] = true;
}
bool solve(vector<int> comp) {
for (auto u: comp) {
for (auto v: comp) {
if (cnt[u][v] == 0) {
return false;
}
}
}
for (int i = 0; i < (int)comp.size() - 1; i++) {
add_edge(comp[i], comp[i + 1]);
}
return true;
}
int construct(vector<vector<int>> _cnt) {
n = _cnt.size();
res.resize(n, vector<int>(n, 0));
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cnt[i][j] = _cnt[i][j];
if (cnt[i][j] == 3) {
return 0;
}
}
}
for (int i = 0; i < n; i++) {
if (!flag[i]) {
flag[i] = true;
vector<int> comp = {i};
int pt = 0;
int sz = 1;
while (pt < sz) {
int u = comp[pt++];
for (int v = 0; v < n; v++) {
if (!flag[v] && cnt[u][v] > 0) {
flag[v] = true;
comp.push_back(v);
sz++;
}
}
}
if (!solve(comp)) {
return 0;
}
}
}
build(res);
return 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
7 ms |
2084 KB |
Output is correct |
7 |
Correct |
153 ms |
26612 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
7 ms |
2084 KB |
Output is correct |
7 |
Correct |
153 ms |
26612 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
7 ms |
1980 KB |
Output is correct |
13 |
Correct |
159 ms |
26620 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
340 KB |
Output is correct |
16 |
Correct |
3 ms |
1620 KB |
Output is correct |
17 |
Correct |
66 ms |
17076 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
38 ms |
8196 KB |
Output is correct |
21 |
Correct |
150 ms |
26692 KB |
Output is correct |
22 |
Correct |
149 ms |
26588 KB |
Output is correct |
23 |
Correct |
155 ms |
26688 KB |
Output is correct |
24 |
Correct |
150 ms |
26644 KB |
Output is correct |
25 |
Correct |
63 ms |
17108 KB |
Output is correct |
26 |
Correct |
63 ms |
17116 KB |
Output is correct |
27 |
Correct |
158 ms |
26680 KB |
Output is correct |
28 |
Correct |
149 ms |
26700 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
304 KB |
Output is correct |
2 |
Correct |
0 ms |
308 KB |
Output is correct |
3 |
Correct |
1 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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
308 KB |
Output is correct |
2 |
Incorrect |
1 ms |
304 KB |
Too few ways to get from 0 to 1, should be 2 found 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
7 ms |
2084 KB |
Output is correct |
7 |
Correct |
153 ms |
26612 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
7 ms |
1980 KB |
Output is correct |
13 |
Correct |
159 ms |
26620 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
340 KB |
Output is correct |
16 |
Correct |
3 ms |
1620 KB |
Output is correct |
17 |
Correct |
66 ms |
17076 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
38 ms |
8196 KB |
Output is correct |
21 |
Correct |
150 ms |
26692 KB |
Output is correct |
22 |
Correct |
149 ms |
26588 KB |
Output is correct |
23 |
Correct |
155 ms |
26688 KB |
Output is correct |
24 |
Correct |
150 ms |
26644 KB |
Output is correct |
25 |
Correct |
63 ms |
17108 KB |
Output is correct |
26 |
Correct |
63 ms |
17116 KB |
Output is correct |
27 |
Correct |
158 ms |
26680 KB |
Output is correct |
28 |
Correct |
149 ms |
26700 KB |
Output is correct |
29 |
Correct |
1 ms |
304 KB |
Output is correct |
30 |
Correct |
0 ms |
308 KB |
Output is correct |
31 |
Correct |
1 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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
7 ms |
2084 KB |
Output is correct |
7 |
Correct |
153 ms |
26612 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
7 ms |
1980 KB |
Output is correct |
13 |
Correct |
159 ms |
26620 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
340 KB |
Output is correct |
16 |
Correct |
3 ms |
1620 KB |
Output is correct |
17 |
Correct |
66 ms |
17076 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
38 ms |
8196 KB |
Output is correct |
21 |
Correct |
150 ms |
26692 KB |
Output is correct |
22 |
Correct |
149 ms |
26588 KB |
Output is correct |
23 |
Correct |
155 ms |
26688 KB |
Output is correct |
24 |
Correct |
150 ms |
26644 KB |
Output is correct |
25 |
Correct |
63 ms |
17108 KB |
Output is correct |
26 |
Correct |
63 ms |
17116 KB |
Output is correct |
27 |
Correct |
158 ms |
26680 KB |
Output is correct |
28 |
Correct |
149 ms |
26700 KB |
Output is correct |
29 |
Correct |
1 ms |
304 KB |
Output is correct |
30 |
Correct |
0 ms |
308 KB |
Output is correct |
31 |
Correct |
1 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 |
- |