#include "parks.h"
#include <bits/stdc++.h>
using namespace std;
int construct_roads(std::vector<int> x, std::vector<int> y) {
if (x.size() == 1) {
build({}, {}, {}, {});
return 1;
}
int n = x.size();
int mn = *min_element(x.begin(), x.end());
int mx = *min_element(x.begin(), x.end());
if (mn == 2 && mx == 2) {
int p[n];
for (int i = 0; i < n; i++) p[i] = i;
sort(p, p + n, [&](int i, int j) {
return y[i] < y[j];
});
for (int i = 0; i + 1 < n; i++)
if (y[p[i]] + 2 != y[p[i + 1]])
return 0;
vector<int> u, v, a, b;
for (int i = 0; i + 1 < n; i++) {
u.push_back(p[i]);
v.push_back(p[i + 1]);
a.push_back(x[i] - 1);
b.push_back(y[p[i]] + 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:32:1: warning: control reaches end of non-void function [-Wreturn-type]
32 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
292 KB |
Output is correct |
9 |
Correct |
58 ms |
7892 KB |
Output is correct |
10 |
Correct |
5 ms |
1228 KB |
Output is correct |
11 |
Correct |
25 ms |
4420 KB |
Output is correct |
12 |
Correct |
8 ms |
1612 KB |
Output is correct |
13 |
Correct |
7 ms |
1484 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
59 ms |
7808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
292 KB |
Output is correct |
9 |
Correct |
58 ms |
7892 KB |
Output is correct |
10 |
Correct |
5 ms |
1228 KB |
Output is correct |
11 |
Correct |
25 ms |
4420 KB |
Output is correct |
12 |
Correct |
8 ms |
1612 KB |
Output is correct |
13 |
Correct |
7 ms |
1484 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
59 ms |
7808 KB |
Output is correct |
17 |
Incorrect |
0 ms |
204 KB |
Solution announced impossible, but it is possible. |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
292 KB |
Output is correct |
9 |
Correct |
58 ms |
7892 KB |
Output is correct |
10 |
Correct |
5 ms |
1228 KB |
Output is correct |
11 |
Correct |
25 ms |
4420 KB |
Output is correct |
12 |
Correct |
8 ms |
1612 KB |
Output is correct |
13 |
Correct |
7 ms |
1484 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
59 ms |
7808 KB |
Output is correct |
17 |
Incorrect |
0 ms |
204 KB |
Solution announced impossible, but it is possible. |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
292 KB |
Output is correct |
9 |
Correct |
58 ms |
7892 KB |
Output is correct |
10 |
Correct |
5 ms |
1228 KB |
Output is correct |
11 |
Correct |
25 ms |
4420 KB |
Output is correct |
12 |
Correct |
8 ms |
1612 KB |
Output is correct |
13 |
Correct |
7 ms |
1484 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
59 ms |
7808 KB |
Output is correct |
17 |
Incorrect |
1 ms |
204 KB |
Solution announced impossible, but it is possible. |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
292 KB |
Output is correct |
9 |
Correct |
58 ms |
7892 KB |
Output is correct |
10 |
Correct |
5 ms |
1228 KB |
Output is correct |
11 |
Correct |
25 ms |
4420 KB |
Output is correct |
12 |
Correct |
8 ms |
1612 KB |
Output is correct |
13 |
Correct |
7 ms |
1484 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
59 ms |
7808 KB |
Output is correct |
17 |
Incorrect |
51 ms |
6200 KB |
Solution announced impossible, but it is possible. |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
292 KB |
Output is correct |
9 |
Correct |
58 ms |
7892 KB |
Output is correct |
10 |
Correct |
5 ms |
1228 KB |
Output is correct |
11 |
Correct |
25 ms |
4420 KB |
Output is correct |
12 |
Correct |
8 ms |
1612 KB |
Output is correct |
13 |
Correct |
7 ms |
1484 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
59 ms |
7808 KB |
Output is correct |
17 |
Incorrect |
0 ms |
204 KB |
Solution announced impossible, but it is possible. |
18 |
Halted |
0 ms |
0 KB |
- |