#include "parks.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n';
#define ll long long int
const int N = 3e5+10;
int construct_roads(std::vector<int> x, std::vector<int> y) {
if (x.size() == 1) {
build({}, {}, {}, {});
return 1;
}
int n = x.size();
vector<int> u, v, a, b;
vector<pair<int, int>> F;
for(int i = 0; i < n; ++i) F.pb({y[i], i});
sort(all(F));
for(int i = 0; i < n - 1; ++i){
if(F[i + 1].first - F[i].first > 2){
return 0;
}
u.pb(F[i].second);
v.pb(F[i + 1].second);
a.pb(1);
b.pb(F[i].first+F[i+1].first>>1);
}
build(u, v, a, b);
return 1;
}
Compilation message
parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)':
parks.cpp:30:24: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
30 | b.pb(F[i].first+F[i+1].first>>1);
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
500 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
52 ms |
9084 KB |
Output is correct |
10 |
Correct |
5 ms |
1288 KB |
Output is correct |
11 |
Correct |
22 ms |
4996 KB |
Output is correct |
12 |
Correct |
7 ms |
1760 KB |
Output is correct |
13 |
Correct |
8 ms |
2516 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
50 ms |
8972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
500 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
52 ms |
9084 KB |
Output is correct |
10 |
Correct |
5 ms |
1288 KB |
Output is correct |
11 |
Correct |
22 ms |
4996 KB |
Output is correct |
12 |
Correct |
7 ms |
1760 KB |
Output is correct |
13 |
Correct |
8 ms |
2516 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
50 ms |
8972 KB |
Output is correct |
17 |
Incorrect |
0 ms |
600 KB |
b[0] = 2 is not an odd integer |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
500 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
52 ms |
9084 KB |
Output is correct |
10 |
Correct |
5 ms |
1288 KB |
Output is correct |
11 |
Correct |
22 ms |
4996 KB |
Output is correct |
12 |
Correct |
7 ms |
1760 KB |
Output is correct |
13 |
Correct |
8 ms |
2516 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
50 ms |
8972 KB |
Output is correct |
17 |
Incorrect |
0 ms |
600 KB |
b[0] = 2 is not an odd integer |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
500 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
52 ms |
9084 KB |
Output is correct |
10 |
Correct |
5 ms |
1288 KB |
Output is correct |
11 |
Correct |
22 ms |
4996 KB |
Output is correct |
12 |
Correct |
7 ms |
1760 KB |
Output is correct |
13 |
Correct |
8 ms |
2516 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
50 ms |
8972 KB |
Output is correct |
17 |
Incorrect |
0 ms |
348 KB |
b[0] = 2 is not an odd integer |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
500 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
52 ms |
9084 KB |
Output is correct |
10 |
Correct |
5 ms |
1288 KB |
Output is correct |
11 |
Correct |
22 ms |
4996 KB |
Output is correct |
12 |
Correct |
7 ms |
1760 KB |
Output is correct |
13 |
Correct |
8 ms |
2516 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
50 ms |
8972 KB |
Output is correct |
17 |
Incorrect |
100 ms |
18104 KB |
Pair u[0]=2 @(82816, 2) and v[0]=3 @(97624, 2) does not form a valid edge (distance != 2) |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
500 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
52 ms |
9084 KB |
Output is correct |
10 |
Correct |
5 ms |
1288 KB |
Output is correct |
11 |
Correct |
22 ms |
4996 KB |
Output is correct |
12 |
Correct |
7 ms |
1760 KB |
Output is correct |
13 |
Correct |
8 ms |
2516 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
50 ms |
8972 KB |
Output is correct |
17 |
Incorrect |
0 ms |
600 KB |
b[0] = 2 is not an odd integer |
18 |
Halted |
0 ms |
0 KB |
- |