#include "parks.h"
#include <bits/stdc++.h>
using namespace std;
int construct_roads(vector<int> x, vector<int> y)
{
if (x.size() == 1)
{
build({}, {}, {}, {});
return 1;
}
// x[i] = 2
const int N = x.size();
vector<pair<int, int>> h(N);
for (int i = 0; i < N; i++)
h[i] = {y[i], i};
sort(h.begin(), h.end());
vector<int> u(N-1), v(N-1), a(N-1), b(N-1);
for (int i = 0; i < N - 1; i++)
{
if (h[i].first + 2 != h[i+1].first) return 0;
u[i] = h[i].second; v[i] = h[i+1].second;
a[i] = x[0] - 1; b[i] = h[i].first + 1;
}
build(u, v, a, b);
return 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 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 |
436 KB |
Output is correct |
9 |
Correct |
35 ms |
8284 KB |
Output is correct |
10 |
Correct |
5 ms |
1216 KB |
Output is correct |
11 |
Correct |
15 ms |
4444 KB |
Output is correct |
12 |
Correct |
5 ms |
1628 KB |
Output is correct |
13 |
Correct |
7 ms |
2392 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
41 ms |
8284 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 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 |
436 KB |
Output is correct |
9 |
Correct |
35 ms |
8284 KB |
Output is correct |
10 |
Correct |
5 ms |
1216 KB |
Output is correct |
11 |
Correct |
15 ms |
4444 KB |
Output is correct |
12 |
Correct |
5 ms |
1628 KB |
Output is correct |
13 |
Correct |
7 ms |
2392 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
41 ms |
8284 KB |
Output is correct |
17 |
Incorrect |
0 ms |
348 KB |
Solution announced impossible, but it is possible. |
18 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 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 |
436 KB |
Output is correct |
9 |
Correct |
35 ms |
8284 KB |
Output is correct |
10 |
Correct |
5 ms |
1216 KB |
Output is correct |
11 |
Correct |
15 ms |
4444 KB |
Output is correct |
12 |
Correct |
5 ms |
1628 KB |
Output is correct |
13 |
Correct |
7 ms |
2392 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
41 ms |
8284 KB |
Output is correct |
17 |
Incorrect |
0 ms |
348 KB |
Solution announced impossible, but it is possible. |
18 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 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 |
436 KB |
Output is correct |
9 |
Correct |
35 ms |
8284 KB |
Output is correct |
10 |
Correct |
5 ms |
1216 KB |
Output is correct |
11 |
Correct |
15 ms |
4444 KB |
Output is correct |
12 |
Correct |
5 ms |
1628 KB |
Output is correct |
13 |
Correct |
7 ms |
2392 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
41 ms |
8284 KB |
Output is correct |
17 |
Incorrect |
1 ms |
432 KB |
Solution announced impossible, but it is possible. |
18 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 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 |
436 KB |
Output is correct |
9 |
Correct |
35 ms |
8284 KB |
Output is correct |
10 |
Correct |
5 ms |
1216 KB |
Output is correct |
11 |
Correct |
15 ms |
4444 KB |
Output is correct |
12 |
Correct |
5 ms |
1628 KB |
Output is correct |
13 |
Correct |
7 ms |
2392 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
41 ms |
8284 KB |
Output is correct |
17 |
Incorrect |
53 ms |
10232 KB |
Solution announced impossible, but it is possible. |
18 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 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 |
436 KB |
Output is correct |
9 |
Correct |
35 ms |
8284 KB |
Output is correct |
10 |
Correct |
5 ms |
1216 KB |
Output is correct |
11 |
Correct |
15 ms |
4444 KB |
Output is correct |
12 |
Correct |
5 ms |
1628 KB |
Output is correct |
13 |
Correct |
7 ms |
2392 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
41 ms |
8284 KB |
Output is correct |
17 |
Incorrect |
0 ms |
348 KB |
Solution announced impossible, but it is possible. |
18 |
Halted |
0 ms |
0 KB |
- |