#include <bits/stdc++.h>
using namespace std;
#include "parks.h"
#define pb push_back
#define fi first
#define se second
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<int,int>> tab(n);
for (int i = 0; i < n; ++i) tab[i]={y[i],i};
sort(tab.begin(),tab.end());
bool test=true;
for (int i = 1; i < n; ++i)
{
if(tab[i].fi-tab[i-1].fi>2) test=false;
}
if(!test) return 0;
for (int i = 0; i < n-1; ++i)
{
a.pb(3);
b.pb(tab[i].fi+1);
u.pb(tab[i+1].se);
v.pb(tab[i].se);
}
build(u, v, a, b);
return 1;
}
# |
Verdict |
Execution time |
Memory |
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 |
35 ms |
8372 KB |
Output is correct |
10 |
Correct |
3 ms |
1372 KB |
Output is correct |
11 |
Correct |
13 ms |
4820 KB |
Output is correct |
12 |
Correct |
4 ms |
1880 KB |
Output is correct |
13 |
Correct |
4 ms |
1628 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
31 ms |
8340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
35 ms |
8372 KB |
Output is correct |
10 |
Correct |
3 ms |
1372 KB |
Output is correct |
11 |
Correct |
13 ms |
4820 KB |
Output is correct |
12 |
Correct |
4 ms |
1880 KB |
Output is correct |
13 |
Correct |
4 ms |
1628 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
31 ms |
8340 KB |
Output is correct |
17 |
Incorrect |
0 ms |
344 KB |
Pair u[1]=0 @(4, 4) and v[1]=3 @(2, 2) does not form a valid edge (distance != 2) |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
35 ms |
8372 KB |
Output is correct |
10 |
Correct |
3 ms |
1372 KB |
Output is correct |
11 |
Correct |
13 ms |
4820 KB |
Output is correct |
12 |
Correct |
4 ms |
1880 KB |
Output is correct |
13 |
Correct |
4 ms |
1628 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
31 ms |
8340 KB |
Output is correct |
17 |
Incorrect |
0 ms |
344 KB |
Pair u[1]=0 @(4, 4) and v[1]=3 @(2, 2) does not form a valid edge (distance != 2) |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
35 ms |
8372 KB |
Output is correct |
10 |
Correct |
3 ms |
1372 KB |
Output is correct |
11 |
Correct |
13 ms |
4820 KB |
Output is correct |
12 |
Correct |
4 ms |
1880 KB |
Output is correct |
13 |
Correct |
4 ms |
1628 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
31 ms |
8340 KB |
Output is correct |
17 |
Incorrect |
0 ms |
348 KB |
Tree (a[0], b[0]) = (3, 3) is not adjacent to edge between u[0]=2 @(199998, 2) and v[0]=0 @(200000, 2) |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
35 ms |
8372 KB |
Output is correct |
10 |
Correct |
3 ms |
1372 KB |
Output is correct |
11 |
Correct |
13 ms |
4820 KB |
Output is correct |
12 |
Correct |
4 ms |
1880 KB |
Output is correct |
13 |
Correct |
4 ms |
1628 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
31 ms |
8340 KB |
Output is correct |
17 |
Incorrect |
73 ms |
16592 KB |
Pair u[0]=3 @(97624, 2) and v[0]=2 @(82816, 2) does not form a valid edge (distance != 2) |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
35 ms |
8372 KB |
Output is correct |
10 |
Correct |
3 ms |
1372 KB |
Output is correct |
11 |
Correct |
13 ms |
4820 KB |
Output is correct |
12 |
Correct |
4 ms |
1880 KB |
Output is correct |
13 |
Correct |
4 ms |
1628 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
31 ms |
8340 KB |
Output is correct |
17 |
Incorrect |
0 ms |
344 KB |
Pair u[1]=0 @(4, 4) and v[1]=3 @(2, 2) does not form a valid edge (distance != 2) |
18 |
Halted |
0 ms |
0 KB |
- |