#include "parks.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll cad[7][200004]={ };
int construct_roads(std::vector<int> x, std::vector<int> y) {
if (x.size() == 1) {
build({}, {}, {}, {});
return 1;
}
ll n=x.size();
for(int i=0; i<n; i++)
{
cad[x[i]][y[i]]=i+1;
}
n=200001;
std::vector<int> u, v, a, b;
ll pl=0;
for(int i=2; i<n; i+=2)
{
if(cad[2][i]==0&&cad[4][i]==0&&cad[6][i]==0&&cad[2][i-2]!=0&&cad[4][i-2]!=0&&cad[6][i-2]!=0)
{
if(pl==1)
{
build(u, v, a, b);
return 0;
}
pl=1;
}
if(cad[2][i]!=0&&cad[2][i+2]!=0)
{
u.push_back(cad[2][i]-1);
v.push_back(cad[2][i+2]-1);
a.push_back(1);
b.push_back(i+1);
}
if(cad[6][i]!=0&&cad[6][i+2]!=0)
{
u.push_back(cad[6][i]-1);
v.push_back(cad[6][i+2]-1);
a.push_back(7);
b.push_back(i+1);
}
}
for(int i=2; i<n; i+=2)
{
if(cad[4][i]!=0&&cad[4][i+2]==0)
{
if(cad[2][i]!=0)
{
u.push_back(cad[2][i]-1);
v.push_back(cad[4][i]-1);
a.push_back(3);
b.push_back(i+1);
}
if(cad[6][i]!=0)
{
u.push_back(cad[4][i]-1);
v.push_back(cad[6][i]-1);
a.push_back(5);
b.push_back(i+1);
}
}
else if(cad[4][i]!=0&&cad[2][i+2]==0&&cad[2][i]!=0&&cad[6][i+2]==0&&cad[6][i]!=0)
{
u.push_back(cad[4][i]-1);
v.push_back(cad[4][i+2]-1);
a.push_back(3);
b.push_back(i+1);
u.push_back(cad[2][i]-1);
v.push_back(cad[4][i]-1);
a.push_back(3);
b.push_back(i-1);
u.push_back(cad[6][i]-1);
v.push_back(cad[4][i]-1);
a.push_back(5);
b.push_back(i+1);
}
else if(cad[4][i]!=0&&cad[2][i+2]==0&&cad[2][i]!=0)
{
u.push_back(cad[4][i]-1);
v.push_back(cad[4][i+2]-1);
a.push_back(5);
b.push_back(i+1);
u.push_back(cad[2][i]);
v.push_back(cad[4][i]);
a.push_back(3);
b.push_back(i+1);
}
else if(cad[4][i]!=0&&cad[6][i+2]==0&&cad[6][i]!=0)
{
u.push_back(cad[4][i]-1);
v.push_back(cad[4][i+2]-1);
a.push_back(3);
b.push_back(i+1);
u.push_back(cad[6][i]-1);
v.push_back(cad[4][i]-1);
a.push_back(5);
b.push_back(i+1);
}
else if(cad[4][i]!=0&&cad[4][i+2]!=0)
{
u.push_back(cad[4][i]-1);
v.push_back(cad[4][i+2]-1);
a.push_back(5);
b.push_back(i+1);
}
}
/*for(int i=0; i<a.size(); i++)
{
cout<<u[i]<<" "<<v[i]<<" "<<a[i]<<" "<<b[i]<<"\n";
}*/
build(u, v, a, b);
return 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Given structure is not connected: There is no path between vertices 0 and 1 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Given structure is not connected: There is no path between vertices 0 and 1 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Given structure is not connected: There is no path between vertices 0 and 1 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Given structure is not connected: There is no path between vertices 0 and 1 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Given structure is not connected: There is no path between vertices 0 and 1 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Given structure is not connected: There is no path between vertices 0 and 1 |
4 |
Halted |
0 ms |
0 KB |
- |