using namespace std;
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
typedef long long LL;
typedef pair<int,int> pii;
#define pb push_back
#define mkp make_pair
#define F first
#define S second
#define REP(n) for (int __=n;__--;)
#define REP1(i,n) for (int i=1;i<=n;++i)
#define REP0(i,n) for (int i=0;i<n;++i)
typedef vector <int> vi;
#include "parks.h"
int dx[4] = {2,-2,0,0},dy[4] = {0,0,2,-2};
map <pii,bool> vis;
void dfs(int x,int y){
vis[mkp(x,y)] = true;
REP0(i,4) if (vis.find(mkp(x+dx[i],y+dy[i])) != vis.end() and !vis[mkp(x+dx[i],y+dy[i])]){
dfs(x+dx[i],y+dy[i]);
}
}
int construct_roads(vi x,vi y){
int n = x.size();
vi u,v,fx,fy;
REP0(i,n) vis[mkp(x[i],y[i])] = false;
dfs(x[0],y[0]);
for (auto [p,v]:vis) if (!v) return false;
map <pii,int> mp;
REP0(i,n) mp[mkp(x[i],y[i])] = i;
REP0(i,n){
if (mp.find(mkp(x[i]+2,y[i])) != mp.end()){
u.pb(i);
v.pb(mp[mkp(x[i]+2,y[i])]);
fx.pb(3);
fy.pb(y[i]-1);
}
if (mp.find(mkp(x[i],y[i]+2)) != mp.end()){
u.pb(i);
v.pb(mp[mkp(x[i],y[i]+2)]);
if (x[i] == 2) fx.pb(1);
else fx.pb(5);
fy.pb(y[i]+1);
}
}
build(u,v,fx,fy);
return true;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
296 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
198 ms |
28592 KB |
Output is correct |
10 |
Correct |
15 ms |
3404 KB |
Output is correct |
11 |
Correct |
98 ms |
15932 KB |
Output is correct |
12 |
Correct |
23 ms |
4892 KB |
Output is correct |
13 |
Correct |
34 ms |
6940 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
460 KB |
Output is correct |
16 |
Correct |
202 ms |
24844 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
296 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
198 ms |
28592 KB |
Output is correct |
10 |
Correct |
15 ms |
3404 KB |
Output is correct |
11 |
Correct |
98 ms |
15932 KB |
Output is correct |
12 |
Correct |
23 ms |
4892 KB |
Output is correct |
13 |
Correct |
34 ms |
6940 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
460 KB |
Output is correct |
16 |
Correct |
202 ms |
24844 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
0 ms |
204 KB |
Output is correct |
20 |
Correct |
0 ms |
204 KB |
Output is correct |
21 |
Correct |
0 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
638 ms |
60928 KB |
Output is correct |
24 |
Correct |
0 ms |
204 KB |
Output is correct |
25 |
Correct |
2 ms |
588 KB |
Output is correct |
26 |
Correct |
2 ms |
588 KB |
Output is correct |
27 |
Correct |
2 ms |
588 KB |
Output is correct |
28 |
Correct |
201 ms |
25420 KB |
Output is correct |
29 |
Correct |
311 ms |
35356 KB |
Output is correct |
30 |
Correct |
455 ms |
49432 KB |
Output is correct |
31 |
Correct |
625 ms |
59276 KB |
Output is correct |
32 |
Correct |
0 ms |
204 KB |
Output is correct |
33 |
Correct |
0 ms |
204 KB |
Output is correct |
34 |
Correct |
0 ms |
236 KB |
Output is correct |
35 |
Correct |
0 ms |
204 KB |
Output is correct |
36 |
Correct |
0 ms |
204 KB |
Output is correct |
37 |
Correct |
0 ms |
204 KB |
Output is correct |
38 |
Correct |
0 ms |
296 KB |
Output is correct |
39 |
Correct |
1 ms |
204 KB |
Output is correct |
40 |
Correct |
0 ms |
204 KB |
Output is correct |
41 |
Correct |
0 ms |
204 KB |
Output is correct |
42 |
Correct |
0 ms |
204 KB |
Output is correct |
43 |
Correct |
1 ms |
460 KB |
Output is correct |
44 |
Correct |
2 ms |
588 KB |
Output is correct |
45 |
Correct |
220 ms |
25792 KB |
Output is correct |
46 |
Correct |
371 ms |
37788 KB |
Output is correct |
47 |
Correct |
359 ms |
37272 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
296 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
198 ms |
28592 KB |
Output is correct |
10 |
Correct |
15 ms |
3404 KB |
Output is correct |
11 |
Correct |
98 ms |
15932 KB |
Output is correct |
12 |
Correct |
23 ms |
4892 KB |
Output is correct |
13 |
Correct |
34 ms |
6940 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
460 KB |
Output is correct |
16 |
Correct |
202 ms |
24844 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
0 ms |
204 KB |
Output is correct |
20 |
Correct |
0 ms |
204 KB |
Output is correct |
21 |
Correct |
0 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
638 ms |
60928 KB |
Output is correct |
24 |
Correct |
0 ms |
204 KB |
Output is correct |
25 |
Correct |
2 ms |
588 KB |
Output is correct |
26 |
Correct |
2 ms |
588 KB |
Output is correct |
27 |
Correct |
2 ms |
588 KB |
Output is correct |
28 |
Correct |
201 ms |
25420 KB |
Output is correct |
29 |
Correct |
311 ms |
35356 KB |
Output is correct |
30 |
Correct |
455 ms |
49432 KB |
Output is correct |
31 |
Correct |
625 ms |
59276 KB |
Output is correct |
32 |
Correct |
0 ms |
204 KB |
Output is correct |
33 |
Correct |
0 ms |
204 KB |
Output is correct |
34 |
Correct |
0 ms |
236 KB |
Output is correct |
35 |
Correct |
0 ms |
204 KB |
Output is correct |
36 |
Correct |
0 ms |
204 KB |
Output is correct |
37 |
Correct |
0 ms |
204 KB |
Output is correct |
38 |
Correct |
0 ms |
296 KB |
Output is correct |
39 |
Correct |
1 ms |
204 KB |
Output is correct |
40 |
Correct |
0 ms |
204 KB |
Output is correct |
41 |
Correct |
0 ms |
204 KB |
Output is correct |
42 |
Correct |
0 ms |
204 KB |
Output is correct |
43 |
Correct |
1 ms |
460 KB |
Output is correct |
44 |
Correct |
2 ms |
588 KB |
Output is correct |
45 |
Correct |
220 ms |
25792 KB |
Output is correct |
46 |
Correct |
371 ms |
37788 KB |
Output is correct |
47 |
Correct |
359 ms |
37272 KB |
Output is correct |
48 |
Incorrect |
0 ms |
204 KB |
Tree (a[1], b[1]) = (3, 1) is not adjacent to edge between u[1]=1 @(4, 2) and v[1]=0 @(6, 2) |
49 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
296 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
198 ms |
28592 KB |
Output is correct |
10 |
Correct |
15 ms |
3404 KB |
Output is correct |
11 |
Correct |
98 ms |
15932 KB |
Output is correct |
12 |
Correct |
23 ms |
4892 KB |
Output is correct |
13 |
Correct |
34 ms |
6940 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
460 KB |
Output is correct |
16 |
Correct |
202 ms |
24844 KB |
Output is correct |
17 |
Incorrect |
0 ms |
204 KB |
Tree (a[0], b[0]) = (5, 3) is not adjacent to edge between u[0]=0 @(200000, 2) and v[0]=1 @(200000, 4) |
18 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
296 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
198 ms |
28592 KB |
Output is correct |
10 |
Correct |
15 ms |
3404 KB |
Output is correct |
11 |
Correct |
98 ms |
15932 KB |
Output is correct |
12 |
Correct |
23 ms |
4892 KB |
Output is correct |
13 |
Correct |
34 ms |
6940 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
460 KB |
Output is correct |
16 |
Correct |
202 ms |
24844 KB |
Output is correct |
17 |
Incorrect |
589 ms |
58736 KB |
Tree (a[0], b[0]) = (3, 100001) is not adjacent to edge between u[0]=0 @(82422, 100002) and v[0]=168975 @(82424, 100002) |
18 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
296 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
198 ms |
28592 KB |
Output is correct |
10 |
Correct |
15 ms |
3404 KB |
Output is correct |
11 |
Correct |
98 ms |
15932 KB |
Output is correct |
12 |
Correct |
23 ms |
4892 KB |
Output is correct |
13 |
Correct |
34 ms |
6940 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
460 KB |
Output is correct |
16 |
Correct |
202 ms |
24844 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
0 ms |
204 KB |
Output is correct |
20 |
Correct |
0 ms |
204 KB |
Output is correct |
21 |
Correct |
0 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
638 ms |
60928 KB |
Output is correct |
24 |
Correct |
0 ms |
204 KB |
Output is correct |
25 |
Correct |
2 ms |
588 KB |
Output is correct |
26 |
Correct |
2 ms |
588 KB |
Output is correct |
27 |
Correct |
2 ms |
588 KB |
Output is correct |
28 |
Correct |
201 ms |
25420 KB |
Output is correct |
29 |
Correct |
311 ms |
35356 KB |
Output is correct |
30 |
Correct |
455 ms |
49432 KB |
Output is correct |
31 |
Correct |
625 ms |
59276 KB |
Output is correct |
32 |
Correct |
0 ms |
204 KB |
Output is correct |
33 |
Correct |
0 ms |
204 KB |
Output is correct |
34 |
Correct |
0 ms |
236 KB |
Output is correct |
35 |
Correct |
0 ms |
204 KB |
Output is correct |
36 |
Correct |
0 ms |
204 KB |
Output is correct |
37 |
Correct |
0 ms |
204 KB |
Output is correct |
38 |
Correct |
0 ms |
296 KB |
Output is correct |
39 |
Correct |
1 ms |
204 KB |
Output is correct |
40 |
Correct |
0 ms |
204 KB |
Output is correct |
41 |
Correct |
0 ms |
204 KB |
Output is correct |
42 |
Correct |
0 ms |
204 KB |
Output is correct |
43 |
Correct |
1 ms |
460 KB |
Output is correct |
44 |
Correct |
2 ms |
588 KB |
Output is correct |
45 |
Correct |
220 ms |
25792 KB |
Output is correct |
46 |
Correct |
371 ms |
37788 KB |
Output is correct |
47 |
Correct |
359 ms |
37272 KB |
Output is correct |
48 |
Incorrect |
0 ms |
204 KB |
Tree (a[1], b[1]) = (3, 1) is not adjacent to edge between u[1]=1 @(4, 2) and v[1]=0 @(6, 2) |
49 |
Halted |
0 ms |
0 KB |
- |