#include "parks.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define pii pair<int,int>
const int mxn=2e5+100;
int n,color[mxn],say;
int l[4]={0,0,2,-2};
int r[4]={2,-2,0,0};
bool qq=true;
vector<int>a,b,c,d;
map<pii,int>arr;
map<pii,bool>cl;
void dfs(int x,int y,int cost){
color[cost]=1;
say++;
for(int i=0;i<4;i++){
int u=x+l[i],v=y+r[i];
int k=arr[{u,v}];
if(k&&!color[k]){
a.pb(cost-1);
b.pb(k-1);
int q1=(x+u)/2,q2=(v+y)/2;
if(q1%2==0){
if(q1==2){
q1--;
}
else{
q1++;
}
//if()
}
else{
if(q2==2){
q2--;
}
else{
q2++;
}
}
if(cl[{q1,q2}]){
qq=false;
}
cl[{q1,q2}]=1;
c.pb(q1);
d.pb(q2);
dfs(u,v,k);
}
}
}
int construct_roads(vector<int> x, vector<int> y) {
n=x.size();
int a1=-1e7,b1=-1e7,a2=1e7,b2=1e7;
for(int i=0;i<n;i++){
a1=max(a1,x[i]);
b1=max(b1,y[i]);
a2=min(a2,x[i]);
b2=min(b2,y[i]);
arr[{x[i],y[i]}]=i+1;
}
dfs(a2,b2,arr[{a2,b2}]);
if(say==n){
build(a,b,c,d);
return 1;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
0 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 |
232 ms |
44488 KB |
Output is correct |
10 |
Correct |
16 ms |
4812 KB |
Output is correct |
11 |
Correct |
97 ms |
24076 KB |
Output is correct |
12 |
Correct |
26 ms |
7124 KB |
Output is correct |
13 |
Correct |
66 ms |
13840 KB |
Output is correct |
14 |
Correct |
1 ms |
460 KB |
Output is correct |
15 |
Correct |
2 ms |
588 KB |
Output is correct |
16 |
Correct |
242 ms |
44488 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 |
0 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 |
232 ms |
44488 KB |
Output is correct |
10 |
Correct |
16 ms |
4812 KB |
Output is correct |
11 |
Correct |
97 ms |
24076 KB |
Output is correct |
12 |
Correct |
26 ms |
7124 KB |
Output is correct |
13 |
Correct |
66 ms |
13840 KB |
Output is correct |
14 |
Correct |
1 ms |
460 KB |
Output is correct |
15 |
Correct |
2 ms |
588 KB |
Output is correct |
16 |
Correct |
242 ms |
44488 KB |
Output is correct |
17 |
Correct |
0 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 |
304 KB |
Output is correct |
22 |
Correct |
1 ms |
300 KB |
Output is correct |
23 |
Correct |
467 ms |
76320 KB |
Output is correct |
24 |
Correct |
1 ms |
288 KB |
Output is correct |
25 |
Correct |
2 ms |
696 KB |
Output is correct |
26 |
Correct |
4 ms |
976 KB |
Output is correct |
27 |
Correct |
4 ms |
800 KB |
Output is correct |
28 |
Correct |
176 ms |
30700 KB |
Output is correct |
29 |
Correct |
265 ms |
45900 KB |
Output is correct |
30 |
Correct |
339 ms |
61108 KB |
Output is correct |
31 |
Correct |
463 ms |
76340 KB |
Output is correct |
32 |
Correct |
1 ms |
204 KB |
Output is correct |
33 |
Correct |
0 ms |
204 KB |
Output is correct |
34 |
Correct |
0 ms |
204 KB |
Output is correct |
35 |
Correct |
0 ms |
304 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 |
204 KB |
Output is correct |
39 |
Correct |
1 ms |
308 KB |
Output is correct |
40 |
Incorrect |
0 ms |
204 KB |
Solution announced impossible, but it is possible. |
41 |
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 |
0 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 |
232 ms |
44488 KB |
Output is correct |
10 |
Correct |
16 ms |
4812 KB |
Output is correct |
11 |
Correct |
97 ms |
24076 KB |
Output is correct |
12 |
Correct |
26 ms |
7124 KB |
Output is correct |
13 |
Correct |
66 ms |
13840 KB |
Output is correct |
14 |
Correct |
1 ms |
460 KB |
Output is correct |
15 |
Correct |
2 ms |
588 KB |
Output is correct |
16 |
Correct |
242 ms |
44488 KB |
Output is correct |
17 |
Correct |
0 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 |
304 KB |
Output is correct |
22 |
Correct |
1 ms |
300 KB |
Output is correct |
23 |
Correct |
467 ms |
76320 KB |
Output is correct |
24 |
Correct |
1 ms |
288 KB |
Output is correct |
25 |
Correct |
2 ms |
696 KB |
Output is correct |
26 |
Correct |
4 ms |
976 KB |
Output is correct |
27 |
Correct |
4 ms |
800 KB |
Output is correct |
28 |
Correct |
176 ms |
30700 KB |
Output is correct |
29 |
Correct |
265 ms |
45900 KB |
Output is correct |
30 |
Correct |
339 ms |
61108 KB |
Output is correct |
31 |
Correct |
463 ms |
76340 KB |
Output is correct |
32 |
Correct |
1 ms |
204 KB |
Output is correct |
33 |
Correct |
0 ms |
204 KB |
Output is correct |
34 |
Correct |
0 ms |
204 KB |
Output is correct |
35 |
Correct |
0 ms |
304 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 |
204 KB |
Output is correct |
39 |
Correct |
1 ms |
308 KB |
Output is correct |
40 |
Incorrect |
0 ms |
204 KB |
Solution announced impossible, but it is possible. |
41 |
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 |
0 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 |
232 ms |
44488 KB |
Output is correct |
10 |
Correct |
16 ms |
4812 KB |
Output is correct |
11 |
Correct |
97 ms |
24076 KB |
Output is correct |
12 |
Correct |
26 ms |
7124 KB |
Output is correct |
13 |
Correct |
66 ms |
13840 KB |
Output is correct |
14 |
Correct |
1 ms |
460 KB |
Output is correct |
15 |
Correct |
2 ms |
588 KB |
Output is correct |
16 |
Correct |
242 ms |
44488 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Incorrect |
0 ms |
204 KB |
Solution announced impossible, but it is possible. |
19 |
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 |
0 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 |
232 ms |
44488 KB |
Output is correct |
10 |
Correct |
16 ms |
4812 KB |
Output is correct |
11 |
Correct |
97 ms |
24076 KB |
Output is correct |
12 |
Correct |
26 ms |
7124 KB |
Output is correct |
13 |
Correct |
66 ms |
13840 KB |
Output is correct |
14 |
Correct |
1 ms |
460 KB |
Output is correct |
15 |
Correct |
2 ms |
588 KB |
Output is correct |
16 |
Correct |
242 ms |
44488 KB |
Output is correct |
17 |
Correct |
506 ms |
88868 KB |
Output is correct |
18 |
Correct |
497 ms |
82768 KB |
Output is correct |
19 |
Incorrect |
163 ms |
16216 KB |
Solution announced impossible, but it is possible. |
20 |
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 |
0 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 |
232 ms |
44488 KB |
Output is correct |
10 |
Correct |
16 ms |
4812 KB |
Output is correct |
11 |
Correct |
97 ms |
24076 KB |
Output is correct |
12 |
Correct |
26 ms |
7124 KB |
Output is correct |
13 |
Correct |
66 ms |
13840 KB |
Output is correct |
14 |
Correct |
1 ms |
460 KB |
Output is correct |
15 |
Correct |
2 ms |
588 KB |
Output is correct |
16 |
Correct |
242 ms |
44488 KB |
Output is correct |
17 |
Correct |
0 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 |
304 KB |
Output is correct |
22 |
Correct |
1 ms |
300 KB |
Output is correct |
23 |
Correct |
467 ms |
76320 KB |
Output is correct |
24 |
Correct |
1 ms |
288 KB |
Output is correct |
25 |
Correct |
2 ms |
696 KB |
Output is correct |
26 |
Correct |
4 ms |
976 KB |
Output is correct |
27 |
Correct |
4 ms |
800 KB |
Output is correct |
28 |
Correct |
176 ms |
30700 KB |
Output is correct |
29 |
Correct |
265 ms |
45900 KB |
Output is correct |
30 |
Correct |
339 ms |
61108 KB |
Output is correct |
31 |
Correct |
463 ms |
76340 KB |
Output is correct |
32 |
Correct |
1 ms |
204 KB |
Output is correct |
33 |
Correct |
0 ms |
204 KB |
Output is correct |
34 |
Correct |
0 ms |
204 KB |
Output is correct |
35 |
Correct |
0 ms |
304 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 |
204 KB |
Output is correct |
39 |
Correct |
1 ms |
308 KB |
Output is correct |
40 |
Incorrect |
0 ms |
204 KB |
Solution announced impossible, but it is possible. |
41 |
Halted |
0 ms |
0 KB |
- |