#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[5][mxn],arr[5][mxn],say;
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});
while(q.size()){
pii p=q.front();
q.pop();
x=p.F,y=p.S;
color[x][y]=1;
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);
c.pb(x+1);
d.pb((v+y)/2);
q.push({u,v});
}
}
}
}
int construct_roads(vector<int> x, vector<int> y) {
n=x.size();
int pos=1e7;
for(int i=0;i<n;i++){
pos=min(pos,y[i]);
arr[x[i]][y[i]]=i+1;
}
bfs(2,pos);
if(say==n){
build(a,b,c,d);
return 1;
}
return 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Incorrect |
0 ms |
204 KB |
Wrong answer detected in grader |
4 |
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 |
Incorrect |
0 ms |
204 KB |
Wrong answer detected in grader |
4 |
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 |
Incorrect |
0 ms |
204 KB |
Wrong answer detected in grader |
4 |
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 |
Incorrect |
0 ms |
204 KB |
Wrong answer detected in grader |
4 |
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 |
Incorrect |
0 ms |
204 KB |
Wrong answer detected in grader |
4 |
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 |
Incorrect |
0 ms |
204 KB |
Wrong answer detected in grader |
4 |
Halted |
0 ms |
0 KB |
- |