#include "parks.h"
#include <bits/stdc++.h>
using namespace std;
#define forn(i,n) for(int i=0;i<n;++i)
#define pb push_back
#define all(x) x.begin(), x.end()
#define pi pair<int,int>
#define f first
#define s second
int construct_roads(vector<int> x, vector<int> y) {
int n=x.size();
vector<int> u,v,a,b;
map<pi,int> m;
forn(i,n) m[{x[i],y[i]}]=i;
vector<pi> z={{-2,0},{2,0},{0,-2},{0,2}};
forn(i,n) {
int f=x[i], s=y[i];
for(auto&x:z) {
if (m.count({f+x.f,s+x.s})) {
if (i<m[{f+x.f,s+x.s}]) {
u.pb(i), v.pb(m[{f+x.f,s+x.s}]);
}
}
}
}
if (u.size()!=n-1) return 0;
forn(i,n-1) {
int x1=x[u[i]], y1=y[u[i]];
int x2=x[v[i]], y2=y[v[i]];
if (x1==x2) {
if ((max(y1,y2)+x1)%4) {
a.pb(x1+1);
b.pb(max(y1,y2)-1);
} else {
a.pb(x1-1);
b.pb(max(y1,y2)-1);
}
} else {
if ((max(x1,x2)+y1)%4) {
a.pb(max(x1,x2)-1);
b.pb(y1-1);
} else {
a.pb(max(x1,x2)-1);
b.pb(y1+1);
}
}
}
build(u,v,a,b);
return 1;
}
Compilation message
parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)':
parks.cpp:28:14: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
28 | if (u.size()!=n-1) return 0;
| ~~~~~~~~^~~~~
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
240 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
131 ms |
13736 KB |
Output is correct |
10 |
Correct |
13 ms |
1740 KB |
Output is correct |
11 |
Correct |
64 ms |
7504 KB |
Output is correct |
12 |
Correct |
16 ms |
2644 KB |
Output is correct |
13 |
Correct |
43 ms |
4668 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
132 ms |
13656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
240 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
131 ms |
13736 KB |
Output is correct |
10 |
Correct |
13 ms |
1740 KB |
Output is correct |
11 |
Correct |
64 ms |
7504 KB |
Output is correct |
12 |
Correct |
16 ms |
2644 KB |
Output is correct |
13 |
Correct |
43 ms |
4668 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
132 ms |
13656 KB |
Output is correct |
17 |
Incorrect |
1 ms |
212 KB |
Solution announced impossible, but it is possible. |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
240 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
131 ms |
13736 KB |
Output is correct |
10 |
Correct |
13 ms |
1740 KB |
Output is correct |
11 |
Correct |
64 ms |
7504 KB |
Output is correct |
12 |
Correct |
16 ms |
2644 KB |
Output is correct |
13 |
Correct |
43 ms |
4668 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
132 ms |
13656 KB |
Output is correct |
17 |
Incorrect |
1 ms |
212 KB |
Solution announced impossible, but it is possible. |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
240 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
131 ms |
13736 KB |
Output is correct |
10 |
Correct |
13 ms |
1740 KB |
Output is correct |
11 |
Correct |
64 ms |
7504 KB |
Output is correct |
12 |
Correct |
16 ms |
2644 KB |
Output is correct |
13 |
Correct |
43 ms |
4668 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
132 ms |
13656 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
416 ms |
28016 KB |
Output is correct |
21 |
Correct |
426 ms |
27824 KB |
Output is correct |
22 |
Correct |
412 ms |
27736 KB |
Output is correct |
23 |
Correct |
286 ms |
23436 KB |
Output is correct |
24 |
Correct |
288 ms |
17636 KB |
Output is correct |
25 |
Correct |
468 ms |
19448 KB |
Output is correct |
26 |
Correct |
341 ms |
19328 KB |
Output is correct |
27 |
Correct |
406 ms |
27104 KB |
Output is correct |
28 |
Correct |
439 ms |
27016 KB |
Output is correct |
29 |
Correct |
552 ms |
27108 KB |
Output is correct |
30 |
Correct |
448 ms |
27108 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Correct |
22 ms |
2500 KB |
Output is correct |
33 |
Correct |
96 ms |
9260 KB |
Output is correct |
34 |
Correct |
342 ms |
27980 KB |
Output is correct |
35 |
Correct |
13 ms |
1372 KB |
Output is correct |
36 |
Correct |
70 ms |
5308 KB |
Output is correct |
37 |
Correct |
146 ms |
10264 KB |
Output is correct |
38 |
Correct |
138 ms |
11632 KB |
Output is correct |
39 |
Correct |
198 ms |
15472 KB |
Output is correct |
40 |
Correct |
274 ms |
19676 KB |
Output is correct |
41 |
Correct |
388 ms |
23972 KB |
Output is correct |
42 |
Correct |
483 ms |
28040 KB |
Output is correct |
43 |
Correct |
0 ms |
296 KB |
Output is correct |
44 |
Correct |
0 ms |
212 KB |
Output is correct |
45 |
Correct |
0 ms |
212 KB |
Output is correct |
46 |
Correct |
0 ms |
212 KB |
Output is correct |
47 |
Correct |
1 ms |
212 KB |
Output is correct |
48 |
Correct |
1 ms |
300 KB |
Output is correct |
49 |
Correct |
1 ms |
212 KB |
Output is correct |
50 |
Correct |
0 ms |
212 KB |
Output is correct |
51 |
Correct |
1 ms |
212 KB |
Output is correct |
52 |
Correct |
0 ms |
212 KB |
Output is correct |
53 |
Correct |
0 ms |
300 KB |
Output is correct |
54 |
Correct |
2 ms |
468 KB |
Output is correct |
55 |
Correct |
3 ms |
596 KB |
Output is correct |
56 |
Correct |
159 ms |
13712 KB |
Output is correct |
57 |
Correct |
241 ms |
19732 KB |
Output is correct |
58 |
Correct |
252 ms |
19684 KB |
Output is correct |
59 |
Correct |
1 ms |
212 KB |
Output is correct |
60 |
Correct |
0 ms |
212 KB |
Output is correct |
61 |
Correct |
0 ms |
212 KB |
Output is correct |
62 |
Correct |
344 ms |
27228 KB |
Output is correct |
63 |
Correct |
327 ms |
27076 KB |
Output is correct |
64 |
Correct |
341 ms |
26924 KB |
Output is correct |
65 |
Correct |
4 ms |
596 KB |
Output is correct |
66 |
Correct |
7 ms |
960 KB |
Output is correct |
67 |
Correct |
159 ms |
13688 KB |
Output is correct |
68 |
Correct |
253 ms |
20416 KB |
Output is correct |
69 |
Correct |
388 ms |
27112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
240 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
131 ms |
13736 KB |
Output is correct |
10 |
Correct |
13 ms |
1740 KB |
Output is correct |
11 |
Correct |
64 ms |
7504 KB |
Output is correct |
12 |
Correct |
16 ms |
2644 KB |
Output is correct |
13 |
Correct |
43 ms |
4668 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
132 ms |
13656 KB |
Output is correct |
17 |
Incorrect |
304 ms |
19912 KB |
Solution announced impossible, but it is possible. |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
240 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
131 ms |
13736 KB |
Output is correct |
10 |
Correct |
13 ms |
1740 KB |
Output is correct |
11 |
Correct |
64 ms |
7504 KB |
Output is correct |
12 |
Correct |
16 ms |
2644 KB |
Output is correct |
13 |
Correct |
43 ms |
4668 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
132 ms |
13656 KB |
Output is correct |
17 |
Incorrect |
1 ms |
212 KB |
Solution announced impossible, but it is possible. |
18 |
Halted |
0 ms |
0 KB |
- |