#include "parks.h"
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define trav(a,v) for(auto a:v)
typedef long long int lld;
#define INF 1000000000000000LL
vector<pair<int,int> >V;
map<pair<int,int>,int> m;
std::vector<int> u, v, X, Y;
void add(int a, int b){
if(m.find({a+1,b+1})!=m.end() && m.find({a+1,b-1})!=m.end()){
u.push_back(m[{a+1,b+1}]);
v.push_back(m[{a+1,b-1}]);
X.push_back(a);
Y.push_back(b);
}
if(m.find({a+1,b+1})!=m.end() && m.find({a-1,b+1})!=m.end()){
u.push_back(m[{a+1,b+1}]);
v.push_back(m[{a-1,b+1}]);
X.push_back(a);
Y.push_back(b);
}
//cout<<a<<" "<<b<<" "<<m[{a-1,b-1}]<<endl;
if(m.find({a-1,b-1})!=m.end() && m.find({a+1,b-1})!=m.end()){
u.push_back(m[{a-1,b-1}]);
v.push_back(m[{a+1,b-1}]);
X.push_back(a);
Y.push_back(b);
}
if(m.find({a-1,b-1})!=m.end() && m.find({a-1,b+1})!=m.end()){
u.push_back(m[{a-1,b-1}]);
v.push_back(m[{a-1,b+1}]);
X.push_back(a);
Y.push_back(b);
}
}
int construct_roads(std::vector<int> x, std::vector<int> y) {
rep(i,0,x.size()){
m[{x[i],y[i]}]=i;
}
add(1,3);
add(3,1);
add(5,3);
add(3,5);
//cout<<u.size()<<endl;
if(u.size()==0 && x.size()>1)return 0;
build(u, v, X, Y);
return 1;
}
Compilation message
parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)':
parks.cpp:5:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
5 | #define rep(i,a,b) for(int i=a;i<b;i++)
......
43 | rep(i,0,x.size()){
| ~~~~~~~~~~~~
parks.cpp:43:2: note: in expansion of macro 'rep'
43 | rep(i,0,x.size()){
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Incorrect |
0 ms |
204 KB |
Given structure is not connected: There is no path between vertices 0 and 3 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Incorrect |
0 ms |
204 KB |
Given structure is not connected: There is no path between vertices 0 and 3 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Incorrect |
0 ms |
204 KB |
Given structure is not connected: There is no path between vertices 0 and 3 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Incorrect |
0 ms |
204 KB |
Given structure is not connected: There is no path between vertices 0 and 3 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Incorrect |
0 ms |
204 KB |
Given structure is not connected: There is no path between vertices 0 and 3 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Incorrect |
0 ms |
204 KB |
Given structure is not connected: There is no path between vertices 0 and 3 |
6 |
Halted |
0 ms |
0 KB |
- |