#include "parks.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
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 dfs(int x,int y){
//cout<<x<<' '<<y<<endl;
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);
dfs(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;
}
dfs(2,pos);
if(say==n){
build(a,b,c,d);
return 1;
}
return 1;
}
# |
Verdict |
Execution time |
Memory |
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 |
- |
# |
Verdict |
Execution time |
Memory |
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 |
- |
# |
Verdict |
Execution time |
Memory |
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 |
- |
# |
Verdict |
Execution time |
Memory |
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 |
- |
# |
Verdict |
Execution time |
Memory |
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 |
- |
# |
Verdict |
Execution time |
Memory |
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 |
- |