#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+5;
int n,color[10][mxn],arr[10][mxn],say,cl[10][mxn];
int l[4]={0,0,2,-2};
int r[4]={2,-2,0,0};
vector<int>a,b,c,d;
void bfs(int x,int y){
queue<pii>q;
q.push({x,y});
color[x][y]=1;
while(q.size()){
pii p=q.front();
q.pop();
x=p.F,y=p.S;
say++;
for(int i=0;i<4;i++){
int u=x+l[i],v=y+r[i];
if(arr[u][v]&&!color[u][v]){
a.pb(arr[x][y]-1);
b.pb(arr[u][v]-1);
int q1=x-1,q2=v-1;
if(x!=u){
q1=(x+u)/2;
if(cl[q1][q2]){
q2+=2;
}
}
else{
q2=(y+v)/2;
if(cl[q1][q2]){
q1+=2;
}
}
cl[q1][q2]=1;
c.pb(q1);
d.pb(q2);
q.push({u,v});
color[u][v]=1;
}
}
}
}
int construct_roads(vector<int> x, vector<int> y) {
n=x.size();
int pos1=1e7,pos=1e7;
for(int i=0;i<n;i++){
pos1=min(pos1,x[i]);
pos=min(pos,y[i]);
arr[x[i]][y[i]]=i+1;
}
bfs(pos1,pos);
if(say==n){
build(a,b,c,d);
return 1;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
332 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
48 ms |
9008 KB |
Output is correct |
10 |
Correct |
5 ms |
1400 KB |
Output is correct |
11 |
Correct |
31 ms |
5080 KB |
Output is correct |
12 |
Correct |
7 ms |
1868 KB |
Output is correct |
13 |
Correct |
8 ms |
2508 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
55 ms |
9004 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
332 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
48 ms |
9008 KB |
Output is correct |
10 |
Correct |
5 ms |
1400 KB |
Output is correct |
11 |
Correct |
31 ms |
5080 KB |
Output is correct |
12 |
Correct |
7 ms |
1868 KB |
Output is correct |
13 |
Correct |
8 ms |
2508 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
55 ms |
9004 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
0 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
0 ms |
332 KB |
Output is correct |
21 |
Correct |
0 ms |
332 KB |
Output is correct |
22 |
Correct |
0 ms |
332 KB |
Output is correct |
23 |
Correct |
107 ms |
17704 KB |
Output is correct |
24 |
Correct |
0 ms |
332 KB |
Output is correct |
25 |
Correct |
1 ms |
460 KB |
Output is correct |
26 |
Correct |
1 ms |
460 KB |
Output is correct |
27 |
Correct |
1 ms |
460 KB |
Output is correct |
28 |
Correct |
39 ms |
7320 KB |
Output is correct |
29 |
Correct |
59 ms |
10824 KB |
Output is correct |
30 |
Correct |
81 ms |
14192 KB |
Output is correct |
31 |
Correct |
105 ms |
17736 KB |
Output is correct |
32 |
Correct |
0 ms |
332 KB |
Output is correct |
33 |
Correct |
0 ms |
332 KB |
Output is correct |
34 |
Correct |
0 ms |
332 KB |
Output is correct |
35 |
Correct |
0 ms |
332 KB |
Output is correct |
36 |
Correct |
0 ms |
332 KB |
Output is correct |
37 |
Correct |
0 ms |
332 KB |
Output is correct |
38 |
Correct |
0 ms |
332 KB |
Output is correct |
39 |
Correct |
1 ms |
332 KB |
Output is correct |
40 |
Incorrect |
0 ms |
332 KB |
Solution announced impossible, but it is possible. |
41 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
332 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
48 ms |
9008 KB |
Output is correct |
10 |
Correct |
5 ms |
1400 KB |
Output is correct |
11 |
Correct |
31 ms |
5080 KB |
Output is correct |
12 |
Correct |
7 ms |
1868 KB |
Output is correct |
13 |
Correct |
8 ms |
2508 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
55 ms |
9004 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
0 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
0 ms |
332 KB |
Output is correct |
21 |
Correct |
0 ms |
332 KB |
Output is correct |
22 |
Correct |
0 ms |
332 KB |
Output is correct |
23 |
Correct |
107 ms |
17704 KB |
Output is correct |
24 |
Correct |
0 ms |
332 KB |
Output is correct |
25 |
Correct |
1 ms |
460 KB |
Output is correct |
26 |
Correct |
1 ms |
460 KB |
Output is correct |
27 |
Correct |
1 ms |
460 KB |
Output is correct |
28 |
Correct |
39 ms |
7320 KB |
Output is correct |
29 |
Correct |
59 ms |
10824 KB |
Output is correct |
30 |
Correct |
81 ms |
14192 KB |
Output is correct |
31 |
Correct |
105 ms |
17736 KB |
Output is correct |
32 |
Correct |
0 ms |
332 KB |
Output is correct |
33 |
Correct |
0 ms |
332 KB |
Output is correct |
34 |
Correct |
0 ms |
332 KB |
Output is correct |
35 |
Correct |
0 ms |
332 KB |
Output is correct |
36 |
Correct |
0 ms |
332 KB |
Output is correct |
37 |
Correct |
0 ms |
332 KB |
Output is correct |
38 |
Correct |
0 ms |
332 KB |
Output is correct |
39 |
Correct |
1 ms |
332 KB |
Output is correct |
40 |
Incorrect |
0 ms |
332 KB |
Solution announced impossible, but it is possible. |
41 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
332 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
48 ms |
9008 KB |
Output is correct |
10 |
Correct |
5 ms |
1400 KB |
Output is correct |
11 |
Correct |
31 ms |
5080 KB |
Output is correct |
12 |
Correct |
7 ms |
1868 KB |
Output is correct |
13 |
Correct |
8 ms |
2508 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
55 ms |
9004 KB |
Output is correct |
17 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 11 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
332 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
48 ms |
9008 KB |
Output is correct |
10 |
Correct |
5 ms |
1400 KB |
Output is correct |
11 |
Correct |
31 ms |
5080 KB |
Output is correct |
12 |
Correct |
7 ms |
1868 KB |
Output is correct |
13 |
Correct |
8 ms |
2508 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
55 ms |
9004 KB |
Output is correct |
17 |
Runtime error |
38 ms |
6724 KB |
Execution killed with signal 11 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
332 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
48 ms |
9008 KB |
Output is correct |
10 |
Correct |
5 ms |
1400 KB |
Output is correct |
11 |
Correct |
31 ms |
5080 KB |
Output is correct |
12 |
Correct |
7 ms |
1868 KB |
Output is correct |
13 |
Correct |
8 ms |
2508 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
55 ms |
9004 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
0 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
0 ms |
332 KB |
Output is correct |
21 |
Correct |
0 ms |
332 KB |
Output is correct |
22 |
Correct |
0 ms |
332 KB |
Output is correct |
23 |
Correct |
107 ms |
17704 KB |
Output is correct |
24 |
Correct |
0 ms |
332 KB |
Output is correct |
25 |
Correct |
1 ms |
460 KB |
Output is correct |
26 |
Correct |
1 ms |
460 KB |
Output is correct |
27 |
Correct |
1 ms |
460 KB |
Output is correct |
28 |
Correct |
39 ms |
7320 KB |
Output is correct |
29 |
Correct |
59 ms |
10824 KB |
Output is correct |
30 |
Correct |
81 ms |
14192 KB |
Output is correct |
31 |
Correct |
105 ms |
17736 KB |
Output is correct |
32 |
Correct |
0 ms |
332 KB |
Output is correct |
33 |
Correct |
0 ms |
332 KB |
Output is correct |
34 |
Correct |
0 ms |
332 KB |
Output is correct |
35 |
Correct |
0 ms |
332 KB |
Output is correct |
36 |
Correct |
0 ms |
332 KB |
Output is correct |
37 |
Correct |
0 ms |
332 KB |
Output is correct |
38 |
Correct |
0 ms |
332 KB |
Output is correct |
39 |
Correct |
1 ms |
332 KB |
Output is correct |
40 |
Incorrect |
0 ms |
332 KB |
Solution announced impossible, but it is possible. |
41 |
Halted |
0 ms |
0 KB |
- |