// --- algolib/bipartite-matching.h ---
// bipartite matching, that optionally finds the bipartition
// some of the functionality is enabled depending on FindBipartition, because
// in the !FindBipartition indices from left and right side coincide, making
// it impossible to provide reasonable return values
// if the graph is not bipartite, max_matching == -1. don't use the other
// functions in such cases.
// usage:
// - construct with either the adjacency list of a graph, or
// ((size left), (size right), adjacency list, containing only l -> r edges)
// for the ladder case, vertices are number [0..l[, [0..r[
// - access matching size using operator int()
// - access matched vertex using [vertex] (first constructor) or
// partner(vertex, left_side)
// - if vertex numbers are distinct, reconstruct the min vertex cover (koenig's
// theorem) using min_vertex_cover()
#include <algorithm>
#include <type_traits>
#include <vector>
template<bool FindBipartition = true>
class MaxBipartiteMatching {
using Graph = std::vector<std::vector<int>>;
Graph e;
int max_matching = 0;
std::vector<bool> vis, on_left;
std::vector<int> match, left;
bool dfs_bipartition(int i, bool is_left) { // false, if not bipartite
vis[i] = true;
on_left[i] = is_left;
if (is_left)
left.push_back(i);
for (int j : e[i])
if (!vis[j])
dfs_bipartition(i, !is_left);
else if (is_left == on_left[j])
return false;
return true;
}
bool augment(int i) {
for (int j : e[i])
if (!vis[j]) {
vis[j] = true;
if (match[j] == -1 || augment(match[j])) {
match[i] = j;
match[j] = i;
return true;
}
}
return false;
}
void find_matching() {
int last;
do {
last = max_matching;
if constexpr (FindBipartition) {
std::fill(vis.begin(), vis.end(), false);
for (int i : left)
if (match[i] == -1)
max_matching += augment(i);
} else {
int size_left = left[0];
std::fill(vis.begin() + size_left, vis.end(), false);
for (int i = 0; i < size_left; i++)
if (match[i] == -1)
max_matching += augment(i);
}
} while (max_matching > last);
}
void dfs_cover(int i) {
vis[i] = true;
for (int j : e[i])
if (!vis[j] && match[i] != j) {
vis[j] = true;
if (int k = match[j]; k != -1 && !vis[k])
dfs_cover(k);
}
}
public:
// given any graph, finds bipartition and matching
template<bool X = FindBipartition, typename std::enable_if_t<X, bool> = false>
MaxBipartiteMatching(const Graph& e_) : e(e_), vis(e.size()),
on_left(e.size()), match(e.size(), -1) {
for (size_t i = 0; i < e.size(); i++) // bipartition
if (!vis[i] && !dfs_bipartition(i, true)) {
max_matching = -1;
return;
}
find_matching();
}
// l vertices [0..l[ on the left, r vertices [0..r[ on the right
// only left -> right edges given
// in theory, a vis array of size r suffices. but in order to make the
// code work with the other constructor, everything becomes terrible
template<bool X = FindBipartition, typename std::enable_if_t<!X, bool> = true>
MaxBipartiteMatching(int l, int r, const Graph& e_) : e(e_), vis(l + r),
match(l + r, -1) {
left.push_back(l);
for (auto& v : e) // shift [0..r[ by l
for (int& i : v)
i += l;
find_matching(); // right -> left edges are not needed
}
// -1, if the graph is not bipartite
operator int() { return max_matching; } // == size(min_vertex_cover)
// Use either [left] or partner. returns -1 if there's no match
template<bool X = FindBipartition>
typename std::enable_if_t<X, int> operator[](int i) { return match[i]; }
template<bool X = FindBipartition>
typename std::enable_if_t<!X, int> partner(int i, bool left_side = true) {
if (left_side) {
int m = match[i];
return m == -1 ? -1 : m - left[0];
}
return match[i + left[0]];
}
template<bool X = FindBipartition>
typename std::enable_if_t<X, std::vector<int>> min_vertex_cover() {
std::fill(vis.begin(), vis.end(), false);
for (int i : left)
if (match[i] == -1)
dfs_cover(i);
std::vector<int> cover;
cover.reserve(max_matching);
for (size_t i = 0; i < vis.size(); i++)
if ((!on_left[i]) == vis[i])
cover.push_back(i);
return cover;
}
};
// ----------------
#include "parks.h"
#include <bits/stdc++.h>
using namespace std;
using Point = pair<int, int>;
set<Point> vis;
map<Point, int> all, fountain; // position => id
vector<int> X, Y;
vector<int> u, v;
vector<Point> v_fountain;
template<typename T> // set or map
bool has(T& set, int x, int y) {
return set.find({ x, y }) != set.end();
}
int id_of_fountain(int x, int y) {
if (!has(fountain, x, y)) {
int id = fountain.size();
fountain.insert({{ x, y }, id});
v_fountain.push_back({ x, y });
return id;
}
return fountain[{ x, y }];
}
int dfs(int i, int x, int y) {
vis.insert({ x, y });
int cnt = 1;
for (auto [xp, yp] : vector<Point>{
{ x+2, y }, { x-2, y }, { x, y+2 }, { x, y-2 }})
if (has(all, xp, yp) && !has(vis, xp, yp)) {
int j = all[{xp, yp}];
u.push_back(i);
v.push_back(j);
cnt += dfs(j, xp, yp);
}
return cnt;
}
int construct_roads(vector<int> x_, vector<int> y_) {
X = x_;
Y = y_;
int n = Y.size();
for (int i = 0; i < n; i++)
all.insert({{ X[i], Y[i] }, i});
if (dfs(0, X[0], Y[0]) != n)
return 0;
vector<vector<int>> g(n - 1); // left side = spanning tree edges
for (int i = 0; i < n - 1; i++)
if (X[u[i]] == X[v[i]]) { // vertical
int x = X[u[i]], y = max(Y[u[i]], Y[v[i]]) - 1;
g[i].push_back(id_of_fountain(x-1, y));
g[i].push_back(id_of_fountain(x+1, y));
} else { // horizontal
int x = max(X[u[i]], X[v[i]]) - 1, y = Y[u[i]];
g[i].push_back(id_of_fountain(x, y-1));
g[i].push_back(id_of_fountain(x, y+1));
}
int m = fountain.size();
MaxBipartiteMatching<false> matching(n-1, m, g);
if (matching != n-1)
return 0;
vector<int> a, b;
for (int i = 0; i < n-1; i++) {
auto [x, y] = v_fountain[matching.partner(i)];
a.push_back(x);
b.push_back(y);
}
build(u, v, a, b);
return 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
377 ms |
63552 KB |
Output is correct |
10 |
Correct |
28 ms |
6760 KB |
Output is correct |
11 |
Correct |
189 ms |
35152 KB |
Output is correct |
12 |
Correct |
43 ms |
9876 KB |
Output is correct |
13 |
Correct |
55 ms |
12780 KB |
Output is correct |
14 |
Correct |
1 ms |
460 KB |
Output is correct |
15 |
Correct |
2 ms |
588 KB |
Output is correct |
16 |
Correct |
382 ms |
55444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
377 ms |
63552 KB |
Output is correct |
10 |
Correct |
28 ms |
6760 KB |
Output is correct |
11 |
Correct |
189 ms |
35152 KB |
Output is correct |
12 |
Correct |
43 ms |
9876 KB |
Output is correct |
13 |
Correct |
55 ms |
12780 KB |
Output is correct |
14 |
Correct |
1 ms |
460 KB |
Output is correct |
15 |
Correct |
2 ms |
588 KB |
Output is correct |
16 |
Correct |
382 ms |
55444 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
827 ms |
110660 KB |
Output is correct |
24 |
Correct |
1 ms |
204 KB |
Output is correct |
25 |
Correct |
3 ms |
844 KB |
Output is correct |
26 |
Correct |
3 ms |
844 KB |
Output is correct |
27 |
Correct |
3 ms |
716 KB |
Output is correct |
28 |
Correct |
272 ms |
45820 KB |
Output is correct |
29 |
Correct |
530 ms |
63152 KB |
Output is correct |
30 |
Correct |
636 ms |
89132 KB |
Output is correct |
31 |
Correct |
846 ms |
106924 KB |
Output is correct |
32 |
Correct |
1 ms |
204 KB |
Output is correct |
33 |
Correct |
1 ms |
204 KB |
Output is correct |
34 |
Correct |
1 ms |
288 KB |
Output is correct |
35 |
Correct |
1 ms |
204 KB |
Output is correct |
36 |
Correct |
1 ms |
204 KB |
Output is correct |
37 |
Correct |
1 ms |
204 KB |
Output is correct |
38 |
Correct |
1 ms |
204 KB |
Output is correct |
39 |
Correct |
1 ms |
204 KB |
Output is correct |
40 |
Correct |
1 ms |
204 KB |
Output is correct |
41 |
Correct |
1 ms |
204 KB |
Output is correct |
42 |
Correct |
1 ms |
204 KB |
Output is correct |
43 |
Correct |
2 ms |
664 KB |
Output is correct |
44 |
Correct |
3 ms |
588 KB |
Output is correct |
45 |
Correct |
342 ms |
53052 KB |
Output is correct |
46 |
Correct |
579 ms |
77068 KB |
Output is correct |
47 |
Correct |
502 ms |
75644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
377 ms |
63552 KB |
Output is correct |
10 |
Correct |
28 ms |
6760 KB |
Output is correct |
11 |
Correct |
189 ms |
35152 KB |
Output is correct |
12 |
Correct |
43 ms |
9876 KB |
Output is correct |
13 |
Correct |
55 ms |
12780 KB |
Output is correct |
14 |
Correct |
1 ms |
460 KB |
Output is correct |
15 |
Correct |
2 ms |
588 KB |
Output is correct |
16 |
Correct |
382 ms |
55444 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
827 ms |
110660 KB |
Output is correct |
24 |
Correct |
1 ms |
204 KB |
Output is correct |
25 |
Correct |
3 ms |
844 KB |
Output is correct |
26 |
Correct |
3 ms |
844 KB |
Output is correct |
27 |
Correct |
3 ms |
716 KB |
Output is correct |
28 |
Correct |
272 ms |
45820 KB |
Output is correct |
29 |
Correct |
530 ms |
63152 KB |
Output is correct |
30 |
Correct |
636 ms |
89132 KB |
Output is correct |
31 |
Correct |
846 ms |
106924 KB |
Output is correct |
32 |
Correct |
1 ms |
204 KB |
Output is correct |
33 |
Correct |
1 ms |
204 KB |
Output is correct |
34 |
Correct |
1 ms |
288 KB |
Output is correct |
35 |
Correct |
1 ms |
204 KB |
Output is correct |
36 |
Correct |
1 ms |
204 KB |
Output is correct |
37 |
Correct |
1 ms |
204 KB |
Output is correct |
38 |
Correct |
1 ms |
204 KB |
Output is correct |
39 |
Correct |
1 ms |
204 KB |
Output is correct |
40 |
Correct |
1 ms |
204 KB |
Output is correct |
41 |
Correct |
1 ms |
204 KB |
Output is correct |
42 |
Correct |
1 ms |
204 KB |
Output is correct |
43 |
Correct |
2 ms |
664 KB |
Output is correct |
44 |
Correct |
3 ms |
588 KB |
Output is correct |
45 |
Correct |
342 ms |
53052 KB |
Output is correct |
46 |
Correct |
579 ms |
77068 KB |
Output is correct |
47 |
Correct |
502 ms |
75644 KB |
Output is correct |
48 |
Correct |
1 ms |
204 KB |
Output is correct |
49 |
Correct |
1 ms |
204 KB |
Output is correct |
50 |
Correct |
1 ms |
204 KB |
Output is correct |
51 |
Correct |
1 ms |
204 KB |
Output is correct |
52 |
Correct |
1 ms |
204 KB |
Output is correct |
53 |
Correct |
1 ms |
204 KB |
Output is correct |
54 |
Correct |
1 ms |
204 KB |
Output is correct |
55 |
Correct |
851 ms |
103596 KB |
Output is correct |
56 |
Correct |
1 ms |
204 KB |
Output is correct |
57 |
Correct |
5 ms |
1228 KB |
Output is correct |
58 |
Correct |
17 ms |
3532 KB |
Output is correct |
59 |
Correct |
7 ms |
1540 KB |
Output is correct |
60 |
Correct |
379 ms |
56444 KB |
Output is correct |
61 |
Correct |
561 ms |
74696 KB |
Output is correct |
62 |
Correct |
637 ms |
86340 KB |
Output is correct |
63 |
Correct |
885 ms |
101016 KB |
Output is correct |
64 |
Correct |
1 ms |
204 KB |
Output is correct |
65 |
Correct |
1 ms |
204 KB |
Output is correct |
66 |
Correct |
1 ms |
204 KB |
Output is correct |
67 |
Correct |
805 ms |
117424 KB |
Output is correct |
68 |
Correct |
748 ms |
118900 KB |
Output is correct |
69 |
Correct |
761 ms |
122992 KB |
Output is correct |
70 |
Correct |
4 ms |
868 KB |
Output is correct |
71 |
Correct |
7 ms |
1260 KB |
Output is correct |
72 |
Correct |
354 ms |
46680 KB |
Output is correct |
73 |
Correct |
539 ms |
74064 KB |
Output is correct |
74 |
Correct |
747 ms |
93364 KB |
Output is correct |
75 |
Correct |
858 ms |
111412 KB |
Output is correct |
76 |
Correct |
840 ms |
130124 KB |
Output is correct |
77 |
Correct |
5 ms |
1228 KB |
Output is correct |
78 |
Correct |
8 ms |
1740 KB |
Output is correct |
79 |
Correct |
352 ms |
50848 KB |
Output is correct |
80 |
Correct |
538 ms |
76864 KB |
Output is correct |
81 |
Correct |
763 ms |
102244 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
377 ms |
63552 KB |
Output is correct |
10 |
Correct |
28 ms |
6760 KB |
Output is correct |
11 |
Correct |
189 ms |
35152 KB |
Output is correct |
12 |
Correct |
43 ms |
9876 KB |
Output is correct |
13 |
Correct |
55 ms |
12780 KB |
Output is correct |
14 |
Correct |
1 ms |
460 KB |
Output is correct |
15 |
Correct |
2 ms |
588 KB |
Output is correct |
16 |
Correct |
382 ms |
55444 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
769 ms |
114096 KB |
Output is correct |
21 |
Correct |
791 ms |
106532 KB |
Output is correct |
22 |
Correct |
803 ms |
100804 KB |
Output is correct |
23 |
Correct |
803 ms |
97668 KB |
Output is correct |
24 |
Correct |
230 ms |
17472 KB |
Output is correct |
25 |
Correct |
193 ms |
17472 KB |
Output is correct |
26 |
Correct |
184 ms |
17600 KB |
Output is correct |
27 |
Correct |
628 ms |
89732 KB |
Output is correct |
28 |
Correct |
684 ms |
89636 KB |
Output is correct |
29 |
Correct |
874 ms |
89676 KB |
Output is correct |
30 |
Correct |
932 ms |
89572 KB |
Output is correct |
31 |
Correct |
1 ms |
204 KB |
Output is correct |
32 |
Correct |
52 ms |
6888 KB |
Output is correct |
33 |
Correct |
73 ms |
8884 KB |
Output is correct |
34 |
Correct |
780 ms |
107248 KB |
Output is correct |
35 |
Correct |
10 ms |
1356 KB |
Output is correct |
36 |
Correct |
41 ms |
5124 KB |
Output is correct |
37 |
Correct |
94 ms |
9400 KB |
Output is correct |
38 |
Correct |
279 ms |
31204 KB |
Output is correct |
39 |
Correct |
348 ms |
42836 KB |
Output is correct |
40 |
Correct |
496 ms |
54108 KB |
Output is correct |
41 |
Correct |
630 ms |
65356 KB |
Output is correct |
42 |
Correct |
725 ms |
77448 KB |
Output is correct |
43 |
Correct |
1 ms |
204 KB |
Output is correct |
44 |
Correct |
1 ms |
204 KB |
Output is correct |
45 |
Correct |
1 ms |
204 KB |
Output is correct |
46 |
Correct |
1 ms |
204 KB |
Output is correct |
47 |
Correct |
1 ms |
204 KB |
Output is correct |
48 |
Correct |
1 ms |
204 KB |
Output is correct |
49 |
Correct |
1 ms |
204 KB |
Output is correct |
50 |
Correct |
1 ms |
204 KB |
Output is correct |
51 |
Correct |
1 ms |
204 KB |
Output is correct |
52 |
Correct |
1 ms |
204 KB |
Output is correct |
53 |
Correct |
1 ms |
204 KB |
Output is correct |
54 |
Correct |
2 ms |
588 KB |
Output is correct |
55 |
Correct |
2 ms |
588 KB |
Output is correct |
56 |
Correct |
324 ms |
53036 KB |
Output is correct |
57 |
Correct |
569 ms |
77096 KB |
Output is correct |
58 |
Correct |
516 ms |
75632 KB |
Output is correct |
59 |
Correct |
1 ms |
204 KB |
Output is correct |
60 |
Correct |
1 ms |
204 KB |
Output is correct |
61 |
Correct |
1 ms |
204 KB |
Output is correct |
62 |
Correct |
822 ms |
117332 KB |
Output is correct |
63 |
Correct |
769 ms |
118948 KB |
Output is correct |
64 |
Correct |
833 ms |
122948 KB |
Output is correct |
65 |
Correct |
4 ms |
844 KB |
Output is correct |
66 |
Correct |
8 ms |
1228 KB |
Output is correct |
67 |
Correct |
416 ms |
46624 KB |
Output is correct |
68 |
Correct |
571 ms |
74172 KB |
Output is correct |
69 |
Correct |
777 ms |
93336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
377 ms |
63552 KB |
Output is correct |
10 |
Correct |
28 ms |
6760 KB |
Output is correct |
11 |
Correct |
189 ms |
35152 KB |
Output is correct |
12 |
Correct |
43 ms |
9876 KB |
Output is correct |
13 |
Correct |
55 ms |
12780 KB |
Output is correct |
14 |
Correct |
1 ms |
460 KB |
Output is correct |
15 |
Correct |
2 ms |
588 KB |
Output is correct |
16 |
Correct |
382 ms |
55444 KB |
Output is correct |
17 |
Correct |
791 ms |
130088 KB |
Output is correct |
18 |
Correct |
799 ms |
113464 KB |
Output is correct |
19 |
Correct |
789 ms |
115176 KB |
Output is correct |
20 |
Correct |
842 ms |
100136 KB |
Output is correct |
21 |
Correct |
732 ms |
89704 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
102 ms |
13700 KB |
Output is correct |
24 |
Correct |
22 ms |
3452 KB |
Output is correct |
25 |
Correct |
65 ms |
7988 KB |
Output is correct |
26 |
Correct |
107 ms |
12180 KB |
Output is correct |
27 |
Correct |
371 ms |
48176 KB |
Output is correct |
28 |
Correct |
567 ms |
59552 KB |
Output is correct |
29 |
Correct |
651 ms |
71744 KB |
Output is correct |
30 |
Correct |
726 ms |
84096 KB |
Output is correct |
31 |
Correct |
871 ms |
95316 KB |
Output is correct |
32 |
Correct |
876 ms |
111552 KB |
Output is correct |
33 |
Correct |
814 ms |
130152 KB |
Output is correct |
34 |
Correct |
7 ms |
1228 KB |
Output is correct |
35 |
Correct |
9 ms |
1796 KB |
Output is correct |
36 |
Correct |
337 ms |
50656 KB |
Output is correct |
37 |
Correct |
547 ms |
76864 KB |
Output is correct |
38 |
Correct |
754 ms |
102628 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
377 ms |
63552 KB |
Output is correct |
10 |
Correct |
28 ms |
6760 KB |
Output is correct |
11 |
Correct |
189 ms |
35152 KB |
Output is correct |
12 |
Correct |
43 ms |
9876 KB |
Output is correct |
13 |
Correct |
55 ms |
12780 KB |
Output is correct |
14 |
Correct |
1 ms |
460 KB |
Output is correct |
15 |
Correct |
2 ms |
588 KB |
Output is correct |
16 |
Correct |
382 ms |
55444 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
827 ms |
110660 KB |
Output is correct |
24 |
Correct |
1 ms |
204 KB |
Output is correct |
25 |
Correct |
3 ms |
844 KB |
Output is correct |
26 |
Correct |
3 ms |
844 KB |
Output is correct |
27 |
Correct |
3 ms |
716 KB |
Output is correct |
28 |
Correct |
272 ms |
45820 KB |
Output is correct |
29 |
Correct |
530 ms |
63152 KB |
Output is correct |
30 |
Correct |
636 ms |
89132 KB |
Output is correct |
31 |
Correct |
846 ms |
106924 KB |
Output is correct |
32 |
Correct |
1 ms |
204 KB |
Output is correct |
33 |
Correct |
1 ms |
204 KB |
Output is correct |
34 |
Correct |
1 ms |
288 KB |
Output is correct |
35 |
Correct |
1 ms |
204 KB |
Output is correct |
36 |
Correct |
1 ms |
204 KB |
Output is correct |
37 |
Correct |
1 ms |
204 KB |
Output is correct |
38 |
Correct |
1 ms |
204 KB |
Output is correct |
39 |
Correct |
1 ms |
204 KB |
Output is correct |
40 |
Correct |
1 ms |
204 KB |
Output is correct |
41 |
Correct |
1 ms |
204 KB |
Output is correct |
42 |
Correct |
1 ms |
204 KB |
Output is correct |
43 |
Correct |
2 ms |
664 KB |
Output is correct |
44 |
Correct |
3 ms |
588 KB |
Output is correct |
45 |
Correct |
342 ms |
53052 KB |
Output is correct |
46 |
Correct |
579 ms |
77068 KB |
Output is correct |
47 |
Correct |
502 ms |
75644 KB |
Output is correct |
48 |
Correct |
1 ms |
204 KB |
Output is correct |
49 |
Correct |
1 ms |
204 KB |
Output is correct |
50 |
Correct |
1 ms |
204 KB |
Output is correct |
51 |
Correct |
1 ms |
204 KB |
Output is correct |
52 |
Correct |
1 ms |
204 KB |
Output is correct |
53 |
Correct |
1 ms |
204 KB |
Output is correct |
54 |
Correct |
1 ms |
204 KB |
Output is correct |
55 |
Correct |
851 ms |
103596 KB |
Output is correct |
56 |
Correct |
1 ms |
204 KB |
Output is correct |
57 |
Correct |
5 ms |
1228 KB |
Output is correct |
58 |
Correct |
17 ms |
3532 KB |
Output is correct |
59 |
Correct |
7 ms |
1540 KB |
Output is correct |
60 |
Correct |
379 ms |
56444 KB |
Output is correct |
61 |
Correct |
561 ms |
74696 KB |
Output is correct |
62 |
Correct |
637 ms |
86340 KB |
Output is correct |
63 |
Correct |
885 ms |
101016 KB |
Output is correct |
64 |
Correct |
1 ms |
204 KB |
Output is correct |
65 |
Correct |
1 ms |
204 KB |
Output is correct |
66 |
Correct |
1 ms |
204 KB |
Output is correct |
67 |
Correct |
805 ms |
117424 KB |
Output is correct |
68 |
Correct |
748 ms |
118900 KB |
Output is correct |
69 |
Correct |
761 ms |
122992 KB |
Output is correct |
70 |
Correct |
4 ms |
868 KB |
Output is correct |
71 |
Correct |
7 ms |
1260 KB |
Output is correct |
72 |
Correct |
354 ms |
46680 KB |
Output is correct |
73 |
Correct |
539 ms |
74064 KB |
Output is correct |
74 |
Correct |
747 ms |
93364 KB |
Output is correct |
75 |
Correct |
858 ms |
111412 KB |
Output is correct |
76 |
Correct |
840 ms |
130124 KB |
Output is correct |
77 |
Correct |
5 ms |
1228 KB |
Output is correct |
78 |
Correct |
8 ms |
1740 KB |
Output is correct |
79 |
Correct |
352 ms |
50848 KB |
Output is correct |
80 |
Correct |
538 ms |
76864 KB |
Output is correct |
81 |
Correct |
763 ms |
102244 KB |
Output is correct |
82 |
Correct |
1 ms |
204 KB |
Output is correct |
83 |
Correct |
1 ms |
204 KB |
Output is correct |
84 |
Correct |
1 ms |
204 KB |
Output is correct |
85 |
Correct |
769 ms |
114096 KB |
Output is correct |
86 |
Correct |
791 ms |
106532 KB |
Output is correct |
87 |
Correct |
803 ms |
100804 KB |
Output is correct |
88 |
Correct |
803 ms |
97668 KB |
Output is correct |
89 |
Correct |
230 ms |
17472 KB |
Output is correct |
90 |
Correct |
193 ms |
17472 KB |
Output is correct |
91 |
Correct |
184 ms |
17600 KB |
Output is correct |
92 |
Correct |
628 ms |
89732 KB |
Output is correct |
93 |
Correct |
684 ms |
89636 KB |
Output is correct |
94 |
Correct |
874 ms |
89676 KB |
Output is correct |
95 |
Correct |
932 ms |
89572 KB |
Output is correct |
96 |
Correct |
1 ms |
204 KB |
Output is correct |
97 |
Correct |
52 ms |
6888 KB |
Output is correct |
98 |
Correct |
73 ms |
8884 KB |
Output is correct |
99 |
Correct |
780 ms |
107248 KB |
Output is correct |
100 |
Correct |
10 ms |
1356 KB |
Output is correct |
101 |
Correct |
41 ms |
5124 KB |
Output is correct |
102 |
Correct |
94 ms |
9400 KB |
Output is correct |
103 |
Correct |
279 ms |
31204 KB |
Output is correct |
104 |
Correct |
348 ms |
42836 KB |
Output is correct |
105 |
Correct |
496 ms |
54108 KB |
Output is correct |
106 |
Correct |
630 ms |
65356 KB |
Output is correct |
107 |
Correct |
725 ms |
77448 KB |
Output is correct |
108 |
Correct |
1 ms |
204 KB |
Output is correct |
109 |
Correct |
1 ms |
204 KB |
Output is correct |
110 |
Correct |
1 ms |
204 KB |
Output is correct |
111 |
Correct |
1 ms |
204 KB |
Output is correct |
112 |
Correct |
1 ms |
204 KB |
Output is correct |
113 |
Correct |
1 ms |
204 KB |
Output is correct |
114 |
Correct |
1 ms |
204 KB |
Output is correct |
115 |
Correct |
1 ms |
204 KB |
Output is correct |
116 |
Correct |
1 ms |
204 KB |
Output is correct |
117 |
Correct |
1 ms |
204 KB |
Output is correct |
118 |
Correct |
1 ms |
204 KB |
Output is correct |
119 |
Correct |
2 ms |
588 KB |
Output is correct |
120 |
Correct |
2 ms |
588 KB |
Output is correct |
121 |
Correct |
324 ms |
53036 KB |
Output is correct |
122 |
Correct |
569 ms |
77096 KB |
Output is correct |
123 |
Correct |
516 ms |
75632 KB |
Output is correct |
124 |
Correct |
1 ms |
204 KB |
Output is correct |
125 |
Correct |
1 ms |
204 KB |
Output is correct |
126 |
Correct |
1 ms |
204 KB |
Output is correct |
127 |
Correct |
822 ms |
117332 KB |
Output is correct |
128 |
Correct |
769 ms |
118948 KB |
Output is correct |
129 |
Correct |
833 ms |
122948 KB |
Output is correct |
130 |
Correct |
4 ms |
844 KB |
Output is correct |
131 |
Correct |
8 ms |
1228 KB |
Output is correct |
132 |
Correct |
416 ms |
46624 KB |
Output is correct |
133 |
Correct |
571 ms |
74172 KB |
Output is correct |
134 |
Correct |
777 ms |
93336 KB |
Output is correct |
135 |
Correct |
791 ms |
130088 KB |
Output is correct |
136 |
Correct |
799 ms |
113464 KB |
Output is correct |
137 |
Correct |
789 ms |
115176 KB |
Output is correct |
138 |
Correct |
842 ms |
100136 KB |
Output is correct |
139 |
Correct |
732 ms |
89704 KB |
Output is correct |
140 |
Correct |
1 ms |
204 KB |
Output is correct |
141 |
Correct |
102 ms |
13700 KB |
Output is correct |
142 |
Correct |
22 ms |
3452 KB |
Output is correct |
143 |
Correct |
65 ms |
7988 KB |
Output is correct |
144 |
Correct |
107 ms |
12180 KB |
Output is correct |
145 |
Correct |
371 ms |
48176 KB |
Output is correct |
146 |
Correct |
567 ms |
59552 KB |
Output is correct |
147 |
Correct |
651 ms |
71744 KB |
Output is correct |
148 |
Correct |
726 ms |
84096 KB |
Output is correct |
149 |
Correct |
871 ms |
95316 KB |
Output is correct |
150 |
Correct |
876 ms |
111552 KB |
Output is correct |
151 |
Correct |
814 ms |
130152 KB |
Output is correct |
152 |
Correct |
7 ms |
1228 KB |
Output is correct |
153 |
Correct |
9 ms |
1796 KB |
Output is correct |
154 |
Correct |
337 ms |
50656 KB |
Output is correct |
155 |
Correct |
547 ms |
76864 KB |
Output is correct |
156 |
Correct |
754 ms |
102628 KB |
Output is correct |
157 |
Correct |
1 ms |
204 KB |
Output is correct |
158 |
Correct |
1 ms |
204 KB |
Output is correct |
159 |
Correct |
1 ms |
204 KB |
Output is correct |
160 |
Correct |
1 ms |
204 KB |
Output is correct |
161 |
Correct |
1012 ms |
98684 KB |
Output is correct |
162 |
Correct |
738 ms |
100528 KB |
Output is correct |
163 |
Correct |
741 ms |
90976 KB |
Output is correct |
164 |
Correct |
721 ms |
89408 KB |
Output is correct |
165 |
Correct |
828 ms |
109876 KB |
Output is correct |
166 |
Correct |
816 ms |
113896 KB |
Output is correct |
167 |
Incorrect |
152 ms |
17276 KB |
Solution announced impossible, but it is possible. |
168 |
Halted |
0 ms |
0 KB |
- |