#include "parks.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vii;
typedef pair<ll,ll> pii;
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
const ll M=2e5+10;
vii v[M];
map<ll,bool>vis[M];
vector<pair<pair<int,int>,int>>segs;
bool contained(pair<pair<int,int>,int> x,pair<pair<int,int>,int>y){
if(x.F.F>y.F.F&&x.F.S<y.F.S)
return 1;
return 0;
}
int construct_roads(std::vector<int> x, std::vector<int> y) {
vector<pair<int,int>>f,m,b;
for(int i=0;i<x.size();i++){
if(x[i]==2){
f.pb({y[i],i});
}
else
b.pb({y[i],i});
}
sort(all(f)),sort(all(m)),sort(all(b));
/*if(f.size()&&(f.back().F-f.front().F)/2!=f.size()-1)
return 0;
if(b.size()&&(b.back().F-b.front().F)/2!=b.size()-1)
return 0;
if(m.size()&&(m.back().F-m.front().F)/2!=m.size()-1)
return 0;
if(m.size()&&f.size()&&(m.back().F<f.front().F||m.front().F>f.back().F))
return 0;
if(b.size()&&m.size()&&(m.back().F<b.front().F||m.front().F>b.back().F))
return 0;*/
vector<int>e1,e2,ax,ay;
for(int i=0;i<ll(f.size())-1;i++){
if(f[i+1].F-f[i].F!=2)
return 0;
e1.pb(f[i].S);
e2.pb(f[i+1].S);
ax.pb(1);
ay.pb(f[i].F+1);
}
for(int i=0;i<ll(b.size())-1;i++){
if(b[i+1].F-b[i].F!=2)
return 0;
e1.pb(b[i].S);
e2.pb(b[i+1].S);
ax.pb(5);
ay.pb(b[i].F+1);
}
if(b.empty()||f.empty()){
build(e1,e2,ax,ay);
return 1;
}
for(int i=2;i<=400000;i+=2){
if(i>=f.front().F&&i<=f.back().F&&i>=b.front().F&&i<=b.back().F){
for(auto it:f){
if(it.F==i){
for(auto itt:b){
if(it.F==i&&itt.F==i){
e1.pb(it.S),e2.pb(itt.S);
ax.pb(3),ay.pb(it.F+1);
build(e1,e2,ax,ay);
return 1;
}
}
}
}
}
}
return 0;
}
Compilation message
parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)':
parks.cpp:22:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | for(int i=0;i<x.size();i++){
| ~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
14424 KB |
Output is correct |
2 |
Correct |
8 ms |
14428 KB |
Output is correct |
3 |
Correct |
7 ms |
14532 KB |
Output is correct |
4 |
Correct |
6 ms |
14428 KB |
Output is correct |
5 |
Correct |
6 ms |
14428 KB |
Output is correct |
6 |
Correct |
6 ms |
14428 KB |
Output is correct |
7 |
Correct |
7 ms |
14428 KB |
Output is correct |
8 |
Correct |
6 ms |
14512 KB |
Output is correct |
9 |
Correct |
44 ms |
23104 KB |
Output is correct |
10 |
Correct |
11 ms |
15332 KB |
Output is correct |
11 |
Correct |
23 ms |
19076 KB |
Output is correct |
12 |
Correct |
11 ms |
15844 KB |
Output is correct |
13 |
Correct |
13 ms |
16592 KB |
Output is correct |
14 |
Correct |
7 ms |
14428 KB |
Output is correct |
15 |
Correct |
6 ms |
14492 KB |
Output is correct |
16 |
Correct |
42 ms |
23188 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
14424 KB |
Output is correct |
2 |
Correct |
8 ms |
14428 KB |
Output is correct |
3 |
Correct |
7 ms |
14532 KB |
Output is correct |
4 |
Correct |
6 ms |
14428 KB |
Output is correct |
5 |
Correct |
6 ms |
14428 KB |
Output is correct |
6 |
Correct |
6 ms |
14428 KB |
Output is correct |
7 |
Correct |
7 ms |
14428 KB |
Output is correct |
8 |
Correct |
6 ms |
14512 KB |
Output is correct |
9 |
Correct |
44 ms |
23104 KB |
Output is correct |
10 |
Correct |
11 ms |
15332 KB |
Output is correct |
11 |
Correct |
23 ms |
19076 KB |
Output is correct |
12 |
Correct |
11 ms |
15844 KB |
Output is correct |
13 |
Correct |
13 ms |
16592 KB |
Output is correct |
14 |
Correct |
7 ms |
14428 KB |
Output is correct |
15 |
Correct |
6 ms |
14492 KB |
Output is correct |
16 |
Correct |
42 ms |
23188 KB |
Output is correct |
17 |
Correct |
6 ms |
14428 KB |
Output is correct |
18 |
Correct |
8 ms |
14428 KB |
Output is correct |
19 |
Correct |
6 ms |
14428 KB |
Output is correct |
20 |
Correct |
6 ms |
14428 KB |
Output is correct |
21 |
Correct |
7 ms |
14448 KB |
Output is correct |
22 |
Correct |
6 ms |
14532 KB |
Output is correct |
23 |
Correct |
82 ms |
30956 KB |
Output is correct |
24 |
Incorrect |
9 ms |
14424 KB |
Solution announced impossible, but it is possible. |
25 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
14424 KB |
Output is correct |
2 |
Correct |
8 ms |
14428 KB |
Output is correct |
3 |
Correct |
7 ms |
14532 KB |
Output is correct |
4 |
Correct |
6 ms |
14428 KB |
Output is correct |
5 |
Correct |
6 ms |
14428 KB |
Output is correct |
6 |
Correct |
6 ms |
14428 KB |
Output is correct |
7 |
Correct |
7 ms |
14428 KB |
Output is correct |
8 |
Correct |
6 ms |
14512 KB |
Output is correct |
9 |
Correct |
44 ms |
23104 KB |
Output is correct |
10 |
Correct |
11 ms |
15332 KB |
Output is correct |
11 |
Correct |
23 ms |
19076 KB |
Output is correct |
12 |
Correct |
11 ms |
15844 KB |
Output is correct |
13 |
Correct |
13 ms |
16592 KB |
Output is correct |
14 |
Correct |
7 ms |
14428 KB |
Output is correct |
15 |
Correct |
6 ms |
14492 KB |
Output is correct |
16 |
Correct |
42 ms |
23188 KB |
Output is correct |
17 |
Correct |
6 ms |
14428 KB |
Output is correct |
18 |
Correct |
8 ms |
14428 KB |
Output is correct |
19 |
Correct |
6 ms |
14428 KB |
Output is correct |
20 |
Correct |
6 ms |
14428 KB |
Output is correct |
21 |
Correct |
7 ms |
14448 KB |
Output is correct |
22 |
Correct |
6 ms |
14532 KB |
Output is correct |
23 |
Correct |
82 ms |
30956 KB |
Output is correct |
24 |
Incorrect |
9 ms |
14424 KB |
Solution announced impossible, but it is possible. |
25 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
14424 KB |
Output is correct |
2 |
Correct |
8 ms |
14428 KB |
Output is correct |
3 |
Correct |
7 ms |
14532 KB |
Output is correct |
4 |
Correct |
6 ms |
14428 KB |
Output is correct |
5 |
Correct |
6 ms |
14428 KB |
Output is correct |
6 |
Correct |
6 ms |
14428 KB |
Output is correct |
7 |
Correct |
7 ms |
14428 KB |
Output is correct |
8 |
Correct |
6 ms |
14512 KB |
Output is correct |
9 |
Correct |
44 ms |
23104 KB |
Output is correct |
10 |
Correct |
11 ms |
15332 KB |
Output is correct |
11 |
Correct |
23 ms |
19076 KB |
Output is correct |
12 |
Correct |
11 ms |
15844 KB |
Output is correct |
13 |
Correct |
13 ms |
16592 KB |
Output is correct |
14 |
Correct |
7 ms |
14428 KB |
Output is correct |
15 |
Correct |
6 ms |
14492 KB |
Output is correct |
16 |
Correct |
42 ms |
23188 KB |
Output is correct |
17 |
Incorrect |
6 ms |
14428 KB |
Solution announced impossible, but it is possible. |
18 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
14424 KB |
Output is correct |
2 |
Correct |
8 ms |
14428 KB |
Output is correct |
3 |
Correct |
7 ms |
14532 KB |
Output is correct |
4 |
Correct |
6 ms |
14428 KB |
Output is correct |
5 |
Correct |
6 ms |
14428 KB |
Output is correct |
6 |
Correct |
6 ms |
14428 KB |
Output is correct |
7 |
Correct |
7 ms |
14428 KB |
Output is correct |
8 |
Correct |
6 ms |
14512 KB |
Output is correct |
9 |
Correct |
44 ms |
23104 KB |
Output is correct |
10 |
Correct |
11 ms |
15332 KB |
Output is correct |
11 |
Correct |
23 ms |
19076 KB |
Output is correct |
12 |
Correct |
11 ms |
15844 KB |
Output is correct |
13 |
Correct |
13 ms |
16592 KB |
Output is correct |
14 |
Correct |
7 ms |
14428 KB |
Output is correct |
15 |
Correct |
6 ms |
14492 KB |
Output is correct |
16 |
Correct |
42 ms |
23188 KB |
Output is correct |
17 |
Incorrect |
47 ms |
22216 KB |
Solution announced impossible, but it is possible. |
18 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
14424 KB |
Output is correct |
2 |
Correct |
8 ms |
14428 KB |
Output is correct |
3 |
Correct |
7 ms |
14532 KB |
Output is correct |
4 |
Correct |
6 ms |
14428 KB |
Output is correct |
5 |
Correct |
6 ms |
14428 KB |
Output is correct |
6 |
Correct |
6 ms |
14428 KB |
Output is correct |
7 |
Correct |
7 ms |
14428 KB |
Output is correct |
8 |
Correct |
6 ms |
14512 KB |
Output is correct |
9 |
Correct |
44 ms |
23104 KB |
Output is correct |
10 |
Correct |
11 ms |
15332 KB |
Output is correct |
11 |
Correct |
23 ms |
19076 KB |
Output is correct |
12 |
Correct |
11 ms |
15844 KB |
Output is correct |
13 |
Correct |
13 ms |
16592 KB |
Output is correct |
14 |
Correct |
7 ms |
14428 KB |
Output is correct |
15 |
Correct |
6 ms |
14492 KB |
Output is correct |
16 |
Correct |
42 ms |
23188 KB |
Output is correct |
17 |
Correct |
6 ms |
14428 KB |
Output is correct |
18 |
Correct |
8 ms |
14428 KB |
Output is correct |
19 |
Correct |
6 ms |
14428 KB |
Output is correct |
20 |
Correct |
6 ms |
14428 KB |
Output is correct |
21 |
Correct |
7 ms |
14448 KB |
Output is correct |
22 |
Correct |
6 ms |
14532 KB |
Output is correct |
23 |
Correct |
82 ms |
30956 KB |
Output is correct |
24 |
Incorrect |
9 ms |
14424 KB |
Solution announced impossible, but it is possible. |
25 |
Halted |
0 ms |
0 KB |
- |