#include "parks.h"
#include <bits/stdc++.h>
using namespace std;
int construct_roads(vector<int>x, vector<int> y) {
vector<int>possible_x(200005,0),possible_y(200005,0);
for(int i = 1 ; i <= x.size() ; i++) possible_x[x[i]]=i;
for(int i = 1 ; i <= y.size() ; i++) possible_y[y[i]]=i;
vector<pair<int,int>>combined(y.size());
for(int i = 0 ; i < y.size() ; i++) {
combined[i].first=x[i],combined[i].second=y[i];
}
vector<int>u(y.size()),v(y.size()),a(y.size()),b(y.size());
for(int i = 0 ; i < y.size() ; i++) {
if(possible_x[combined[i].first-2]) {
u[i]=possible_x[combined[i].first-2]-1;
v[i]=i;
a[i]=combined[i].first+1;
b[i]=combined[i].second+1;
} else if(possible_x[combined[i].first+2]) {
u[i]=possible_x[combined[i].first+2]-1;
v[i]=i;
a[i]=combined[i].first+1;
b[i]=combined[i].second+1;
} else if(possible_y[combined[i].second-2]) {
u[i]=possible_y[combined[i].second-2]-1;
v[i]=i;
a[i]=combined[i].first+1;
b[i]=combined[i].second+1;
} else if(possible_y[combined[i].second+2]) {
u[i]=possible_y[combined[i].second+2]-1;
v[i]=i;
a[i]=combined[i].first+1;
b[i]=combined[i].second+1;
} else {
return 0;
}
}
build(u,v,a,b);
return 1;
}
Compilation message
parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)':
parks.cpp:7:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
7 | for(int i = 1 ; i <= x.size() ; i++) possible_x[x[i]]=i;
| ~~^~~~~~~~~~~
parks.cpp:8:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
8 | for(int i = 1 ; i <= y.size() ; i++) possible_y[y[i]]=i;
| ~~^~~~~~~~~~~
parks.cpp:10:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
10 | for(int i = 0 ; i < y.size() ; i++) {
| ~~^~~~~~~~~~
parks.cpp:14:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
14 | for(int i = 0 ; i < y.size() ; i++) {
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
1740 KB |
Pair u[0]=0 @(2, 2) and v[0]=0 @(2, 2) does not form a valid edge (distance != 2) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
1740 KB |
Pair u[0]=0 @(2, 2) and v[0]=0 @(2, 2) does not form a valid edge (distance != 2) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
1740 KB |
Pair u[0]=0 @(2, 2) and v[0]=0 @(2, 2) does not form a valid edge (distance != 2) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
1740 KB |
Pair u[0]=0 @(2, 2) and v[0]=0 @(2, 2) does not form a valid edge (distance != 2) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
1740 KB |
Pair u[0]=0 @(2, 2) and v[0]=0 @(2, 2) does not form a valid edge (distance != 2) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
1740 KB |
Pair u[0]=0 @(2, 2) and v[0]=0 @(2, 2) does not form a valid edge (distance != 2) |
2 |
Halted |
0 ms |
0 KB |
- |