# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
435577 |
2021-06-23T12:45:58 Z |
grt |
Fountain Parks (IOI21_parks) |
C++17 |
|
929 ms |
126824 KB |
#include <bits/stdc++.h>
#include "parks.h"
#define ST first
#define ND second
#define PB push_back
using namespace std;
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;
const int nax = 800 * 1000 + 10;
map<pi, int>fontain;
pi road[nax];
int n;
vi V[nax], V2[nax];
map<pi, int>pts;
pi inv[nax];
bool vis[nax];
int match[nax];
bool augument(int u) {
vis[u] = true;
for(int v : V[u]) {
if(match[v] == -1) {
match[u] = v;
match[v] = u;
return true;
}
}
for(int v : V[u]) {
if(!vis[match[v]] && augument(match[v])) {
match[u] = v;
match[v] = u;
return true;
}
}
return false;
}
void dfs(int x) {
vis[x] = true;
for(int nbh : V2[x]) if(!vis[nbh]) {
dfs(nbh);
}
}
int construct_roads(vi xx, vi yx) {
for(int i = 0; i < (int)xx.size(); ++i) {
fontain[{xx[i], yx[i]}] = i;
}
for(auto it : fontain) {
auto [x, y] = it.ST;
if(fontain.count({x + 2, y})) {
road[n] = {it.ND, fontain[{x + 2, y}]};
pts[{x + 1, y - 1}];
pts[{x + 1, y + 1}];
n++;
}
if(fontain.count({x, y + 2})) {
road[n] = {it.ND, fontain[{x, y + 2}]};
pts[{x - 1, y + 1}];
pts[{x + 1, y + 1}];
n++;
}
}
int id = 0;
for(auto &it : pts) {
inv[id] = it.ST;
it.ND = id++;
}
for(int i = 0; i < n; ++i) {
V2[road[i].ST].PB(road[i].ND);
V2[road[i].ND].PB(road[i].ST);
int x1 = xx[road[i].ST], y1 = yx[road[i].ST];
int x2 = xx[road[i].ND], y2 = yx[road[i].ND];
if(x1 == x2) {
int y = (y1 + y2) / 2;
for(int x : {x1 - 1, x1 + 1}) {
int nr = pts[{x, y}];
V[i].emplace_back(n + nr);
V[n + nr].emplace_back(i);
}
} else if(y1 == y2) {
int x = (x1 + x2) / 2;
for(int y : {y1 - 1, y1 + 1}) {
int nr = pts[{x, y}];
V[i].emplace_back(n + nr);
V[n + nr].emplace_back(i);
}
}
}
dfs(0);
for(int i = 0; i < (int)xx.size(); ++i) {
if(!vis[i]) {
return 0;
}
}
for(int i = 0; i < n + id; ++i) {
match[i] = -1;
}
while(true) {
bool any = false;
for(int i = 0; i < n + id; ++i) {
vis[i] = false;
}
for(int i = 0; i < n + id; ++i) {
if(match[i] == -1 && augument(i)) {
any = true;
}
}
if(!any) break;
}
for(int i = 0; i < n; ++i) {
if(match[i] == -1) {
return 0;
}
}
vi u(n), v(n), a(n), b(n);
for(int i = 0; i < n; ++i) {
u[i] = road[i].ST;
v[i] = road[i].ND;
a[i] = inv[match[i] - n].ST;
b[i] = inv[match[i] - n].ND;
}
build(u,v,a,b);
return 1;
}
//int main() {
//ios_base::sync_with_stdio(0);
//cin.tie(0);
//}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
37828 KB |
Output is correct |
2 |
Correct |
22 ms |
37964 KB |
Output is correct |
3 |
Correct |
22 ms |
37772 KB |
Output is correct |
4 |
Correct |
23 ms |
37808 KB |
Output is correct |
5 |
Correct |
24 ms |
37892 KB |
Output is correct |
6 |
Correct |
23 ms |
37836 KB |
Output is correct |
7 |
Correct |
22 ms |
37780 KB |
Output is correct |
8 |
Correct |
23 ms |
37844 KB |
Output is correct |
9 |
Correct |
370 ms |
80948 KB |
Output is correct |
10 |
Correct |
46 ms |
42308 KB |
Output is correct |
11 |
Correct |
174 ms |
61088 KB |
Output is correct |
12 |
Correct |
56 ms |
44484 KB |
Output is correct |
13 |
Correct |
117 ms |
53980 KB |
Output is correct |
14 |
Correct |
25 ms |
38152 KB |
Output is correct |
15 |
Correct |
27 ms |
38476 KB |
Output is correct |
16 |
Correct |
368 ms |
80148 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
37828 KB |
Output is correct |
2 |
Correct |
22 ms |
37964 KB |
Output is correct |
3 |
Correct |
22 ms |
37772 KB |
Output is correct |
4 |
Correct |
23 ms |
37808 KB |
Output is correct |
5 |
Correct |
24 ms |
37892 KB |
Output is correct |
6 |
Correct |
23 ms |
37836 KB |
Output is correct |
7 |
Correct |
22 ms |
37780 KB |
Output is correct |
8 |
Correct |
23 ms |
37844 KB |
Output is correct |
9 |
Correct |
370 ms |
80948 KB |
Output is correct |
10 |
Correct |
46 ms |
42308 KB |
Output is correct |
11 |
Correct |
174 ms |
61088 KB |
Output is correct |
12 |
Correct |
56 ms |
44484 KB |
Output is correct |
13 |
Correct |
117 ms |
53980 KB |
Output is correct |
14 |
Correct |
25 ms |
38152 KB |
Output is correct |
15 |
Correct |
27 ms |
38476 KB |
Output is correct |
16 |
Correct |
368 ms |
80148 KB |
Output is correct |
17 |
Correct |
27 ms |
37848 KB |
Output is correct |
18 |
Correct |
25 ms |
37828 KB |
Output is correct |
19 |
Correct |
29 ms |
37796 KB |
Output is correct |
20 |
Correct |
26 ms |
37836 KB |
Output is correct |
21 |
Correct |
22 ms |
37888 KB |
Output is correct |
22 |
Correct |
22 ms |
37800 KB |
Output is correct |
23 |
Correct |
903 ms |
126808 KB |
Output is correct |
24 |
Correct |
21 ms |
37836 KB |
Output is correct |
25 |
Correct |
25 ms |
38424 KB |
Output is correct |
26 |
Correct |
29 ms |
38844 KB |
Output is correct |
27 |
Correct |
31 ms |
39188 KB |
Output is correct |
28 |
Correct |
321 ms |
73532 KB |
Output is correct |
29 |
Correct |
492 ms |
91248 KB |
Output is correct |
30 |
Correct |
699 ms |
109180 KB |
Output is correct |
31 |
Correct |
929 ms |
126824 KB |
Output is correct |
32 |
Correct |
22 ms |
37836 KB |
Output is correct |
33 |
Correct |
22 ms |
37836 KB |
Output is correct |
34 |
Correct |
23 ms |
37836 KB |
Output is correct |
35 |
Correct |
23 ms |
37836 KB |
Output is correct |
36 |
Correct |
22 ms |
37816 KB |
Output is correct |
37 |
Correct |
23 ms |
37836 KB |
Output is correct |
38 |
Correct |
23 ms |
37964 KB |
Output is correct |
39 |
Correct |
22 ms |
37840 KB |
Output is correct |
40 |
Correct |
27 ms |
37836 KB |
Output is correct |
41 |
Correct |
23 ms |
37808 KB |
Output is correct |
42 |
Correct |
21 ms |
37836 KB |
Output is correct |
43 |
Correct |
25 ms |
38420 KB |
Output is correct |
44 |
Correct |
27 ms |
38732 KB |
Output is correct |
45 |
Correct |
341 ms |
73684 KB |
Output is correct |
46 |
Correct |
487 ms |
89908 KB |
Output is correct |
47 |
Correct |
490 ms |
89940 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
37828 KB |
Output is correct |
2 |
Correct |
22 ms |
37964 KB |
Output is correct |
3 |
Correct |
22 ms |
37772 KB |
Output is correct |
4 |
Correct |
23 ms |
37808 KB |
Output is correct |
5 |
Correct |
24 ms |
37892 KB |
Output is correct |
6 |
Correct |
23 ms |
37836 KB |
Output is correct |
7 |
Correct |
22 ms |
37780 KB |
Output is correct |
8 |
Correct |
23 ms |
37844 KB |
Output is correct |
9 |
Correct |
370 ms |
80948 KB |
Output is correct |
10 |
Correct |
46 ms |
42308 KB |
Output is correct |
11 |
Correct |
174 ms |
61088 KB |
Output is correct |
12 |
Correct |
56 ms |
44484 KB |
Output is correct |
13 |
Correct |
117 ms |
53980 KB |
Output is correct |
14 |
Correct |
25 ms |
38152 KB |
Output is correct |
15 |
Correct |
27 ms |
38476 KB |
Output is correct |
16 |
Correct |
368 ms |
80148 KB |
Output is correct |
17 |
Correct |
27 ms |
37848 KB |
Output is correct |
18 |
Correct |
25 ms |
37828 KB |
Output is correct |
19 |
Correct |
29 ms |
37796 KB |
Output is correct |
20 |
Correct |
26 ms |
37836 KB |
Output is correct |
21 |
Correct |
22 ms |
37888 KB |
Output is correct |
22 |
Correct |
22 ms |
37800 KB |
Output is correct |
23 |
Correct |
903 ms |
126808 KB |
Output is correct |
24 |
Correct |
21 ms |
37836 KB |
Output is correct |
25 |
Correct |
25 ms |
38424 KB |
Output is correct |
26 |
Correct |
29 ms |
38844 KB |
Output is correct |
27 |
Correct |
31 ms |
39188 KB |
Output is correct |
28 |
Correct |
321 ms |
73532 KB |
Output is correct |
29 |
Correct |
492 ms |
91248 KB |
Output is correct |
30 |
Correct |
699 ms |
109180 KB |
Output is correct |
31 |
Correct |
929 ms |
126824 KB |
Output is correct |
32 |
Correct |
22 ms |
37836 KB |
Output is correct |
33 |
Correct |
22 ms |
37836 KB |
Output is correct |
34 |
Correct |
23 ms |
37836 KB |
Output is correct |
35 |
Correct |
23 ms |
37836 KB |
Output is correct |
36 |
Correct |
22 ms |
37816 KB |
Output is correct |
37 |
Correct |
23 ms |
37836 KB |
Output is correct |
38 |
Correct |
23 ms |
37964 KB |
Output is correct |
39 |
Correct |
22 ms |
37840 KB |
Output is correct |
40 |
Correct |
27 ms |
37836 KB |
Output is correct |
41 |
Correct |
23 ms |
37808 KB |
Output is correct |
42 |
Correct |
21 ms |
37836 KB |
Output is correct |
43 |
Correct |
25 ms |
38420 KB |
Output is correct |
44 |
Correct |
27 ms |
38732 KB |
Output is correct |
45 |
Correct |
341 ms |
73684 KB |
Output is correct |
46 |
Correct |
487 ms |
89908 KB |
Output is correct |
47 |
Correct |
490 ms |
89940 KB |
Output is correct |
48 |
Correct |
22 ms |
37776 KB |
Output is correct |
49 |
Correct |
24 ms |
37784 KB |
Output is correct |
50 |
Correct |
25 ms |
37848 KB |
Output is correct |
51 |
Correct |
23 ms |
37844 KB |
Output is correct |
52 |
Correct |
23 ms |
37808 KB |
Output is correct |
53 |
Correct |
24 ms |
37852 KB |
Output is correct |
54 |
Correct |
24 ms |
37808 KB |
Output is correct |
55 |
Incorrect |
816 ms |
113296 KB |
Solution announced impossible, but it is possible. |
56 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
37828 KB |
Output is correct |
2 |
Correct |
22 ms |
37964 KB |
Output is correct |
3 |
Correct |
22 ms |
37772 KB |
Output is correct |
4 |
Correct |
23 ms |
37808 KB |
Output is correct |
5 |
Correct |
24 ms |
37892 KB |
Output is correct |
6 |
Correct |
23 ms |
37836 KB |
Output is correct |
7 |
Correct |
22 ms |
37780 KB |
Output is correct |
8 |
Correct |
23 ms |
37844 KB |
Output is correct |
9 |
Correct |
370 ms |
80948 KB |
Output is correct |
10 |
Correct |
46 ms |
42308 KB |
Output is correct |
11 |
Correct |
174 ms |
61088 KB |
Output is correct |
12 |
Correct |
56 ms |
44484 KB |
Output is correct |
13 |
Correct |
117 ms |
53980 KB |
Output is correct |
14 |
Correct |
25 ms |
38152 KB |
Output is correct |
15 |
Correct |
27 ms |
38476 KB |
Output is correct |
16 |
Correct |
368 ms |
80148 KB |
Output is correct |
17 |
Correct |
22 ms |
37836 KB |
Output is correct |
18 |
Correct |
23 ms |
37836 KB |
Output is correct |
19 |
Correct |
25 ms |
37836 KB |
Output is correct |
20 |
Correct |
686 ms |
115080 KB |
Output is correct |
21 |
Correct |
720 ms |
107072 KB |
Output is correct |
22 |
Correct |
776 ms |
107144 KB |
Output is correct |
23 |
Correct |
667 ms |
110148 KB |
Output is correct |
24 |
Correct |
250 ms |
53632 KB |
Output is correct |
25 |
Correct |
646 ms |
108356 KB |
Output is correct |
26 |
Correct |
573 ms |
108356 KB |
Output is correct |
27 |
Correct |
702 ms |
120604 KB |
Output is correct |
28 |
Correct |
679 ms |
120548 KB |
Output is correct |
29 |
Correct |
790 ms |
120608 KB |
Output is correct |
30 |
Correct |
838 ms |
120668 KB |
Output is correct |
31 |
Correct |
24 ms |
37836 KB |
Output is correct |
32 |
Correct |
57 ms |
43024 KB |
Output is correct |
33 |
Correct |
120 ms |
45712 KB |
Output is correct |
34 |
Correct |
734 ms |
114900 KB |
Output is correct |
35 |
Correct |
46 ms |
40524 KB |
Output is correct |
36 |
Correct |
157 ms |
51340 KB |
Output is correct |
37 |
Correct |
281 ms |
64944 KB |
Output is correct |
38 |
Correct |
314 ms |
64136 KB |
Output is correct |
39 |
Correct |
416 ms |
73832 KB |
Output is correct |
40 |
Correct |
505 ms |
83620 KB |
Output is correct |
41 |
Correct |
609 ms |
93476 KB |
Output is correct |
42 |
Correct |
755 ms |
103356 KB |
Output is correct |
43 |
Correct |
26 ms |
37836 KB |
Output is correct |
44 |
Correct |
27 ms |
37844 KB |
Output is correct |
45 |
Correct |
25 ms |
37852 KB |
Output is correct |
46 |
Correct |
29 ms |
37860 KB |
Output is correct |
47 |
Correct |
24 ms |
37848 KB |
Output is correct |
48 |
Correct |
24 ms |
37832 KB |
Output is correct |
49 |
Correct |
24 ms |
37816 KB |
Output is correct |
50 |
Correct |
23 ms |
37860 KB |
Output is correct |
51 |
Correct |
23 ms |
37888 KB |
Output is correct |
52 |
Correct |
25 ms |
37852 KB |
Output is correct |
53 |
Correct |
26 ms |
37816 KB |
Output is correct |
54 |
Correct |
27 ms |
38480 KB |
Output is correct |
55 |
Correct |
32 ms |
38732 KB |
Output is correct |
56 |
Correct |
388 ms |
73648 KB |
Output is correct |
57 |
Correct |
629 ms |
89908 KB |
Output is correct |
58 |
Correct |
533 ms |
89776 KB |
Output is correct |
59 |
Correct |
24 ms |
37836 KB |
Output is correct |
60 |
Correct |
27 ms |
37836 KB |
Output is correct |
61 |
Correct |
22 ms |
37832 KB |
Output is correct |
62 |
Correct |
887 ms |
123084 KB |
Output is correct |
63 |
Correct |
818 ms |
123156 KB |
Output is correct |
64 |
Correct |
747 ms |
123140 KB |
Output is correct |
65 |
Correct |
36 ms |
38980 KB |
Output is correct |
66 |
Correct |
44 ms |
40132 KB |
Output is correct |
67 |
Correct |
423 ms |
72600 KB |
Output is correct |
68 |
Correct |
641 ms |
90436 KB |
Output is correct |
69 |
Correct |
855 ms |
107520 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
37828 KB |
Output is correct |
2 |
Correct |
22 ms |
37964 KB |
Output is correct |
3 |
Correct |
22 ms |
37772 KB |
Output is correct |
4 |
Correct |
23 ms |
37808 KB |
Output is correct |
5 |
Correct |
24 ms |
37892 KB |
Output is correct |
6 |
Correct |
23 ms |
37836 KB |
Output is correct |
7 |
Correct |
22 ms |
37780 KB |
Output is correct |
8 |
Correct |
23 ms |
37844 KB |
Output is correct |
9 |
Correct |
370 ms |
80948 KB |
Output is correct |
10 |
Correct |
46 ms |
42308 KB |
Output is correct |
11 |
Correct |
174 ms |
61088 KB |
Output is correct |
12 |
Correct |
56 ms |
44484 KB |
Output is correct |
13 |
Correct |
117 ms |
53980 KB |
Output is correct |
14 |
Correct |
25 ms |
38152 KB |
Output is correct |
15 |
Correct |
27 ms |
38476 KB |
Output is correct |
16 |
Correct |
368 ms |
80148 KB |
Output is correct |
17 |
Correct |
844 ms |
124164 KB |
Output is correct |
18 |
Correct |
752 ms |
123800 KB |
Output is correct |
19 |
Correct |
741 ms |
103248 KB |
Output is correct |
20 |
Correct |
842 ms |
113600 KB |
Output is correct |
21 |
Correct |
700 ms |
109700 KB |
Output is correct |
22 |
Correct |
25 ms |
37836 KB |
Output is correct |
23 |
Correct |
107 ms |
48868 KB |
Output is correct |
24 |
Correct |
64 ms |
43748 KB |
Output is correct |
25 |
Correct |
189 ms |
58212 KB |
Output is correct |
26 |
Correct |
315 ms |
72704 KB |
Output is correct |
27 |
Correct |
402 ms |
74708 KB |
Output is correct |
28 |
Correct |
509 ms |
83884 KB |
Output is correct |
29 |
Correct |
590 ms |
93136 KB |
Output is correct |
30 |
Correct |
725 ms |
102376 KB |
Output is correct |
31 |
Correct |
798 ms |
111516 KB |
Output is correct |
32 |
Correct |
867 ms |
118540 KB |
Output is correct |
33 |
Correct |
786 ms |
124120 KB |
Output is correct |
34 |
Correct |
32 ms |
39372 KB |
Output is correct |
35 |
Correct |
44 ms |
40612 KB |
Output is correct |
36 |
Correct |
350 ms |
74736 KB |
Output is correct |
37 |
Correct |
590 ms |
93456 KB |
Output is correct |
38 |
Correct |
768 ms |
112372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
37828 KB |
Output is correct |
2 |
Correct |
22 ms |
37964 KB |
Output is correct |
3 |
Correct |
22 ms |
37772 KB |
Output is correct |
4 |
Correct |
23 ms |
37808 KB |
Output is correct |
5 |
Correct |
24 ms |
37892 KB |
Output is correct |
6 |
Correct |
23 ms |
37836 KB |
Output is correct |
7 |
Correct |
22 ms |
37780 KB |
Output is correct |
8 |
Correct |
23 ms |
37844 KB |
Output is correct |
9 |
Correct |
370 ms |
80948 KB |
Output is correct |
10 |
Correct |
46 ms |
42308 KB |
Output is correct |
11 |
Correct |
174 ms |
61088 KB |
Output is correct |
12 |
Correct |
56 ms |
44484 KB |
Output is correct |
13 |
Correct |
117 ms |
53980 KB |
Output is correct |
14 |
Correct |
25 ms |
38152 KB |
Output is correct |
15 |
Correct |
27 ms |
38476 KB |
Output is correct |
16 |
Correct |
368 ms |
80148 KB |
Output is correct |
17 |
Correct |
27 ms |
37848 KB |
Output is correct |
18 |
Correct |
25 ms |
37828 KB |
Output is correct |
19 |
Correct |
29 ms |
37796 KB |
Output is correct |
20 |
Correct |
26 ms |
37836 KB |
Output is correct |
21 |
Correct |
22 ms |
37888 KB |
Output is correct |
22 |
Correct |
22 ms |
37800 KB |
Output is correct |
23 |
Correct |
903 ms |
126808 KB |
Output is correct |
24 |
Correct |
21 ms |
37836 KB |
Output is correct |
25 |
Correct |
25 ms |
38424 KB |
Output is correct |
26 |
Correct |
29 ms |
38844 KB |
Output is correct |
27 |
Correct |
31 ms |
39188 KB |
Output is correct |
28 |
Correct |
321 ms |
73532 KB |
Output is correct |
29 |
Correct |
492 ms |
91248 KB |
Output is correct |
30 |
Correct |
699 ms |
109180 KB |
Output is correct |
31 |
Correct |
929 ms |
126824 KB |
Output is correct |
32 |
Correct |
22 ms |
37836 KB |
Output is correct |
33 |
Correct |
22 ms |
37836 KB |
Output is correct |
34 |
Correct |
23 ms |
37836 KB |
Output is correct |
35 |
Correct |
23 ms |
37836 KB |
Output is correct |
36 |
Correct |
22 ms |
37816 KB |
Output is correct |
37 |
Correct |
23 ms |
37836 KB |
Output is correct |
38 |
Correct |
23 ms |
37964 KB |
Output is correct |
39 |
Correct |
22 ms |
37840 KB |
Output is correct |
40 |
Correct |
27 ms |
37836 KB |
Output is correct |
41 |
Correct |
23 ms |
37808 KB |
Output is correct |
42 |
Correct |
21 ms |
37836 KB |
Output is correct |
43 |
Correct |
25 ms |
38420 KB |
Output is correct |
44 |
Correct |
27 ms |
38732 KB |
Output is correct |
45 |
Correct |
341 ms |
73684 KB |
Output is correct |
46 |
Correct |
487 ms |
89908 KB |
Output is correct |
47 |
Correct |
490 ms |
89940 KB |
Output is correct |
48 |
Correct |
22 ms |
37776 KB |
Output is correct |
49 |
Correct |
24 ms |
37784 KB |
Output is correct |
50 |
Correct |
25 ms |
37848 KB |
Output is correct |
51 |
Correct |
23 ms |
37844 KB |
Output is correct |
52 |
Correct |
23 ms |
37808 KB |
Output is correct |
53 |
Correct |
24 ms |
37852 KB |
Output is correct |
54 |
Correct |
24 ms |
37808 KB |
Output is correct |
55 |
Incorrect |
816 ms |
113296 KB |
Solution announced impossible, but it is possible. |
56 |
Halted |
0 ms |
0 KB |
- |