#include "parks.h"
#include <bits/stdc++.h>
using namespace std;
#define MP make_pair
const int maxn=(2e5)+10;
map<pair<int,int>,int> M;
int n,m,hd,tl;
bool vis[maxn];
int fx[4][2]={{-2,0},{2,0},{0,-2},{0,2}};
int q[maxn];
int construct_roads(vector<int> X,vector<int> Y) {
n=(int)X.size();
vector<int> u,v,a,b;
for (int i=0;i<n;i++) M[MP(X[i],Y[i])]=i;
hd=tl=1; q[1]=0; vis[0]=1;
while (hd<=tl) {
int x=X[q[hd]],y=Y[q[hd]]; hd++;
for (int i=0;i<4;i++) {
int xx=x+fx[i][0],yy=y+fx[i][1];
if (M.count(MP(xx,yy))) {
int id=M[MP(xx,yy)]; if (vis[id]) continue;
vis[id]=1; q[++tl]=id;
}
}
}
if (tl!=n) return 0;
for (int i=0;i<n;i++) {
int x=X[i],y=Y[i];
int A=x+2,B=y;
if (M.count(MP(A,B))) {
u.push_back(i),v.push_back(M[MP(A,B)]);
a.push_back(x+1); if ((x+y)&2) b.push_back(y+1); else b.push_back(y-1);
}
A=x,B=y+2;
if (M.count(MP(A,B))) {
u.push_back(i),v.push_back(M[MP(A,B)]);
if ((x+y)&2) a.push_back(x-1); else a.push_back(x+1); b.push_back(y+1);
}
}
build(u,v,a,b);
return 1;
}
# |
Verdict |
Execution time |
Memory |
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 |
2 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 |
303 ms |
13376 KB |
Output is correct |
10 |
Correct |
16 ms |
1744 KB |
Output is correct |
11 |
Correct |
96 ms |
7412 KB |
Output is correct |
12 |
Correct |
27 ms |
2488 KB |
Output is correct |
13 |
Correct |
40 ms |
3856 KB |
Output is correct |
14 |
Correct |
2 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
464 KB |
Output is correct |
16 |
Correct |
299 ms |
13348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
2 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 |
303 ms |
13376 KB |
Output is correct |
10 |
Correct |
16 ms |
1744 KB |
Output is correct |
11 |
Correct |
96 ms |
7412 KB |
Output is correct |
12 |
Correct |
27 ms |
2488 KB |
Output is correct |
13 |
Correct |
40 ms |
3856 KB |
Output is correct |
14 |
Correct |
2 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
464 KB |
Output is correct |
16 |
Correct |
299 ms |
13348 KB |
Output is correct |
17 |
Incorrect |
1 ms |
204 KB |
Tree @(3, 3) appears more than once: for edges on positions 1 and 3 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
2 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 |
303 ms |
13376 KB |
Output is correct |
10 |
Correct |
16 ms |
1744 KB |
Output is correct |
11 |
Correct |
96 ms |
7412 KB |
Output is correct |
12 |
Correct |
27 ms |
2488 KB |
Output is correct |
13 |
Correct |
40 ms |
3856 KB |
Output is correct |
14 |
Correct |
2 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
464 KB |
Output is correct |
16 |
Correct |
299 ms |
13348 KB |
Output is correct |
17 |
Incorrect |
1 ms |
204 KB |
Tree @(3, 3) appears more than once: for edges on positions 1 and 3 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
2 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 |
303 ms |
13376 KB |
Output is correct |
10 |
Correct |
16 ms |
1744 KB |
Output is correct |
11 |
Correct |
96 ms |
7412 KB |
Output is correct |
12 |
Correct |
27 ms |
2488 KB |
Output is correct |
13 |
Correct |
40 ms |
3856 KB |
Output is correct |
14 |
Correct |
2 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
464 KB |
Output is correct |
16 |
Correct |
299 ms |
13348 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
3 ms |
216 KB |
Output is correct |
20 |
Correct |
781 ms |
26396 KB |
Output is correct |
21 |
Correct |
1026 ms |
26396 KB |
Output is correct |
22 |
Correct |
794 ms |
26464 KB |
Output is correct |
23 |
Correct |
671 ms |
22580 KB |
Output is correct |
24 |
Correct |
269 ms |
15836 KB |
Output is correct |
25 |
Correct |
214 ms |
16084 KB |
Output is correct |
26 |
Correct |
214 ms |
16080 KB |
Output is correct |
27 |
Correct |
828 ms |
26488 KB |
Output is correct |
28 |
Correct |
857 ms |
26512 KB |
Output is correct |
29 |
Correct |
1113 ms |
26412 KB |
Output is correct |
30 |
Correct |
1108 ms |
26444 KB |
Output is correct |
31 |
Correct |
2 ms |
204 KB |
Output is correct |
32 |
Correct |
44 ms |
2472 KB |
Output is correct |
33 |
Correct |
143 ms |
8024 KB |
Output is correct |
34 |
Correct |
996 ms |
26460 KB |
Output is correct |
35 |
Correct |
11 ms |
1100 KB |
Output is correct |
36 |
Correct |
49 ms |
4292 KB |
Output is correct |
37 |
Correct |
107 ms |
8176 KB |
Output is correct |
38 |
Correct |
340 ms |
10864 KB |
Output is correct |
39 |
Correct |
390 ms |
14764 KB |
Output is correct |
40 |
Correct |
600 ms |
18640 KB |
Output is correct |
41 |
Correct |
862 ms |
22628 KB |
Output is correct |
42 |
Correct |
1097 ms |
26504 KB |
Output is correct |
43 |
Correct |
1 ms |
256 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 |
256 KB |
Output is correct |
54 |
Correct |
3 ms |
332 KB |
Output is correct |
55 |
Correct |
2 ms |
460 KB |
Output is correct |
56 |
Correct |
278 ms |
13508 KB |
Output is correct |
57 |
Correct |
491 ms |
19308 KB |
Output is correct |
58 |
Correct |
563 ms |
19372 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 |
595 ms |
26376 KB |
Output is correct |
63 |
Correct |
567 ms |
26456 KB |
Output is correct |
64 |
Correct |
631 ms |
26248 KB |
Output is correct |
65 |
Correct |
3 ms |
588 KB |
Output is correct |
66 |
Correct |
8 ms |
892 KB |
Output is correct |
67 |
Correct |
347 ms |
13440 KB |
Output is correct |
68 |
Correct |
600 ms |
19920 KB |
Output is correct |
69 |
Correct |
929 ms |
26484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
2 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 |
303 ms |
13376 KB |
Output is correct |
10 |
Correct |
16 ms |
1744 KB |
Output is correct |
11 |
Correct |
96 ms |
7412 KB |
Output is correct |
12 |
Correct |
27 ms |
2488 KB |
Output is correct |
13 |
Correct |
40 ms |
3856 KB |
Output is correct |
14 |
Correct |
2 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
464 KB |
Output is correct |
16 |
Correct |
299 ms |
13348 KB |
Output is correct |
17 |
Correct |
695 ms |
26396 KB |
Output is correct |
18 |
Correct |
887 ms |
26408 KB |
Output is correct |
19 |
Correct |
827 ms |
26520 KB |
Output is correct |
20 |
Correct |
896 ms |
28960 KB |
Output is correct |
21 |
Correct |
827 ms |
24188 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
127 ms |
4608 KB |
Output is correct |
24 |
Correct |
18 ms |
1880 KB |
Output is correct |
25 |
Correct |
55 ms |
5828 KB |
Output is correct |
26 |
Correct |
114 ms |
9816 KB |
Output is correct |
27 |
Correct |
466 ms |
14356 KB |
Output is correct |
28 |
Correct |
700 ms |
17840 KB |
Output is correct |
29 |
Correct |
737 ms |
21348 KB |
Output is correct |
30 |
Correct |
905 ms |
24832 KB |
Output is correct |
31 |
Correct |
994 ms |
28224 KB |
Output is correct |
32 |
Correct |
759 ms |
28344 KB |
Output is correct |
33 |
Correct |
630 ms |
26404 KB |
Output is correct |
34 |
Correct |
4 ms |
588 KB |
Output is correct |
35 |
Correct |
7 ms |
972 KB |
Output is correct |
36 |
Correct |
353 ms |
13860 KB |
Output is correct |
37 |
Correct |
499 ms |
20624 KB |
Output is correct |
38 |
Correct |
793 ms |
27384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
2 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 |
303 ms |
13376 KB |
Output is correct |
10 |
Correct |
16 ms |
1744 KB |
Output is correct |
11 |
Correct |
96 ms |
7412 KB |
Output is correct |
12 |
Correct |
27 ms |
2488 KB |
Output is correct |
13 |
Correct |
40 ms |
3856 KB |
Output is correct |
14 |
Correct |
2 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
464 KB |
Output is correct |
16 |
Correct |
299 ms |
13348 KB |
Output is correct |
17 |
Incorrect |
1 ms |
204 KB |
Tree @(3, 3) appears more than once: for edges on positions 1 and 3 |
18 |
Halted |
0 ms |
0 KB |
- |