#include <bits/stdc++.h>
using namespace std;
#include "parks.h"
#define pb push_back
#define fi first
#define se second
const int nax=2e5+5;
int dis(pair<int,int> a,pair<int,int> b){
return abs(a.fi-b.fi)+abs(a.se-b.se);
}
int construct_roads(std::vector<int> x, std::vector<int> y) {
if (x.size() == 1) {
build({}, {}, {}, {});
return 1;
}
std::vector<int> u, v, a, b;
int n=y.size();
vector<pair<pair<int,int>,int>> cor;
for (int i = 0; i < n; ++i) cor.pb({{y[i],x[i]},i});
sort(cor.begin(),cor.end());
bool test=true;
for (int i = 1; i < n; ++i)
{
if(dis(cor[i].fi,cor[i-1].fi)==2) continue;
if(i>1&&dis(cor[i].fi,cor[i-2].fi)==2) continue;
test=false;
}
if(!test) return 0;
for (int i = 0; i < n-1; ++i)
{
if(i<n-2){
if(dis(cor[i].fi,cor[i+2].fi)==2){
if(cor[i].fi.se==2) a.pb(1);
else a.pb(5);
b.pb(cor[i].fi.fi+1);
u.pb(cor[i].se);
v.pb(cor[i+2].se);
}
}
if(dis(cor[i].fi,cor[i+1].fi)!=2) continue;
if(cor[i].fi.se!=cor[i+1].fi.se){
a.pb(3);
b.pb(cor[i].fi.fi-1);
u.pb(cor[i].se);
v.pb(cor[i+1].se);
}else{
if(cor[i].fi.se==2) a.pb(1);
else a.pb(5);
b.pb(cor[i].fi.fi+1);
u.pb(cor[i].se);
v.pb(cor[i+1].se);
}
}
build(u, v, a, b);
return 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
41 ms |
8256 KB |
Output is correct |
10 |
Correct |
6 ms |
1192 KB |
Output is correct |
11 |
Correct |
14 ms |
4580 KB |
Output is correct |
12 |
Correct |
4 ms |
1648 KB |
Output is correct |
13 |
Correct |
5 ms |
1816 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
37 ms |
8188 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
41 ms |
8256 KB |
Output is correct |
10 |
Correct |
6 ms |
1192 KB |
Output is correct |
11 |
Correct |
14 ms |
4580 KB |
Output is correct |
12 |
Correct |
4 ms |
1648 KB |
Output is correct |
13 |
Correct |
5 ms |
1816 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
37 ms |
8188 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
80 ms |
21688 KB |
Output is correct |
24 |
Incorrect |
0 ms |
344 KB |
Solution announced impossible, but it is possible. |
25 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
41 ms |
8256 KB |
Output is correct |
10 |
Correct |
6 ms |
1192 KB |
Output is correct |
11 |
Correct |
14 ms |
4580 KB |
Output is correct |
12 |
Correct |
4 ms |
1648 KB |
Output is correct |
13 |
Correct |
5 ms |
1816 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
37 ms |
8188 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
80 ms |
21688 KB |
Output is correct |
24 |
Incorrect |
0 ms |
344 KB |
Solution announced impossible, but it is possible. |
25 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
41 ms |
8256 KB |
Output is correct |
10 |
Correct |
6 ms |
1192 KB |
Output is correct |
11 |
Correct |
14 ms |
4580 KB |
Output is correct |
12 |
Correct |
4 ms |
1648 KB |
Output is correct |
13 |
Correct |
5 ms |
1816 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
37 ms |
8188 KB |
Output is correct |
17 |
Incorrect |
0 ms |
344 KB |
Tree (a[0], b[0]) = (3, 1) is not adjacent to edge between u[0]=2 @(199998, 2) and v[0]=0 @(200000, 2) |
18 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
41 ms |
8256 KB |
Output is correct |
10 |
Correct |
6 ms |
1192 KB |
Output is correct |
11 |
Correct |
14 ms |
4580 KB |
Output is correct |
12 |
Correct |
4 ms |
1648 KB |
Output is correct |
13 |
Correct |
5 ms |
1816 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
37 ms |
8188 KB |
Output is correct |
17 |
Incorrect |
34 ms |
8148 KB |
Solution announced impossible, but it is possible. |
18 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
41 ms |
8256 KB |
Output is correct |
10 |
Correct |
6 ms |
1192 KB |
Output is correct |
11 |
Correct |
14 ms |
4580 KB |
Output is correct |
12 |
Correct |
4 ms |
1648 KB |
Output is correct |
13 |
Correct |
5 ms |
1816 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
37 ms |
8188 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
80 ms |
21688 KB |
Output is correct |
24 |
Incorrect |
0 ms |
344 KB |
Solution announced impossible, but it is possible. |
25 |
Halted |
0 ms |
0 KB |
- |