#include "supertrees.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include "/home/eagle/ioi19/day2/debug.h"
#else
#define debug(...) void(37)
#endif
int construct(std::vector<std::vector<int>> P) {
int N = int(P.size());
vector<vector<int>> ans(N, vector<int>(N));
auto Add = [&](int x, int y) {
ans[x][y] = ans[y][x] = true;
};
bool bad = false;
auto Group = [&](vector<int> s, function<bool(int)> connected) {
int c = int(s.size());
vector<bool> used(c);
vector<vector<int>> gs;
for (int i = 0; i < c; ++i) {
if (used[i]) {
continue;
}
gs.push_back({s[i]});
for (int j = i + 1; j < c; ++j) {
if (connected(P[s[i]][s[j]])) {
if (used[j]) {
bad = true;
}
used[j] = true;
gs.back().push_back(s[j]);
}
}
for (int j = 0; j < i; ++j) {
bad |= connected(P[s[j]][s[i]]);
}
for (auto x : gs.back()) {
for (auto y : gs.back()) {
bad |= !connected(P[x][y]);
}
}
}
return gs;
};
vector<int> foo(N);
iota(foo.begin(), foo.end(), 0);
auto gs = Group(foo, [&](int x) {
return x != 0;
});
debug(gs);
for (auto g : gs) {
bool two = false, three = false;
for (auto x : g) {
for (auto y : g) {
two |= P[x][y] == 2;
three |= P[x][y] == 3;
}
}
auto ones = Group(g, [&](int x) {
return x == 1;
});
if ((two && three) || (two && int(ones.size()) < 3) || (three && int(ones.size()) < 4)) {
bad = true;
break;
}
for (auto o : ones) {
for (int i = 0; i < int(o.size()) - 1; ++i) {
Add(o[i], o[i + 1]);
}
}
for (int i = 0; i < int(ones.size()) - 1; ++i) {
Add(ones[i][0], ones[i + 1][0]);
}
if (two || three) {
Add(ones[0][0], ones[2][0]);
}
if (three) {
Add(ones[1][0], ones[3][0]);
}
}
if (bad) {
return 0;
}
build(ans);
return 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
296 KB |
Output is correct |
3 |
Correct |
0 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 |
1204 KB |
Output is correct |
7 |
Correct |
151 ms |
22276 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
296 KB |
Output is correct |
3 |
Correct |
0 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 |
1204 KB |
Output is correct |
7 |
Correct |
151 ms |
22276 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
304 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
300 KB |
Output is correct |
12 |
Correct |
6 ms |
1236 KB |
Output is correct |
13 |
Correct |
143 ms |
22356 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
5 ms |
824 KB |
Output is correct |
17 |
Correct |
80 ms |
12528 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
37 ms |
6236 KB |
Output is correct |
21 |
Correct |
150 ms |
24012 KB |
Output is correct |
22 |
Correct |
152 ms |
24020 KB |
Output is correct |
23 |
Correct |
156 ms |
24012 KB |
Output is correct |
24 |
Correct |
145 ms |
24036 KB |
Output is correct |
25 |
Incorrect |
146 ms |
23940 KB |
Answer gives possible 1 while actual possible 0 |
26 |
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 |
300 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
296 KB |
Output is correct |
7 |
Correct |
1 ms |
308 KB |
Output is correct |
8 |
Correct |
6 ms |
1236 KB |
Output is correct |
9 |
Correct |
148 ms |
22472 KB |
Output is correct |
10 |
Incorrect |
0 ms |
296 KB |
Too few ways to get from 2 to 3, should be 2 found 1 |
11 |
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 |
36 ms |
5896 KB |
Output is correct |
5 |
Correct |
151 ms |
22280 KB |
Output is correct |
6 |
Correct |
149 ms |
22336 KB |
Output is correct |
7 |
Correct |
151 ms |
22256 KB |
Output is correct |
8 |
Incorrect |
0 ms |
212 KB |
Too few ways to get from 2 to 3, should be 2 found 1 |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
296 KB |
Output is correct |
3 |
Correct |
0 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 |
1204 KB |
Output is correct |
7 |
Correct |
151 ms |
22276 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
304 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
300 KB |
Output is correct |
12 |
Correct |
6 ms |
1236 KB |
Output is correct |
13 |
Correct |
143 ms |
22356 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
5 ms |
824 KB |
Output is correct |
17 |
Correct |
80 ms |
12528 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
37 ms |
6236 KB |
Output is correct |
21 |
Correct |
150 ms |
24012 KB |
Output is correct |
22 |
Correct |
152 ms |
24020 KB |
Output is correct |
23 |
Correct |
156 ms |
24012 KB |
Output is correct |
24 |
Correct |
145 ms |
24036 KB |
Output is correct |
25 |
Incorrect |
146 ms |
23940 KB |
Answer gives possible 1 while actual possible 0 |
26 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
296 KB |
Output is correct |
3 |
Correct |
0 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 |
1204 KB |
Output is correct |
7 |
Correct |
151 ms |
22276 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
304 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
300 KB |
Output is correct |
12 |
Correct |
6 ms |
1236 KB |
Output is correct |
13 |
Correct |
143 ms |
22356 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
5 ms |
824 KB |
Output is correct |
17 |
Correct |
80 ms |
12528 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
37 ms |
6236 KB |
Output is correct |
21 |
Correct |
150 ms |
24012 KB |
Output is correct |
22 |
Correct |
152 ms |
24020 KB |
Output is correct |
23 |
Correct |
156 ms |
24012 KB |
Output is correct |
24 |
Correct |
145 ms |
24036 KB |
Output is correct |
25 |
Incorrect |
146 ms |
23940 KB |
Answer gives possible 1 while actual possible 0 |
26 |
Halted |
0 ms |
0 KB |
- |