#include "parks.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
struct Coord {
int x, y, i;
bool operator<(Coord other) const {
if (y == other.y) {
return x < other.x;
}
return y < other.y;
}
};
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 = x.size();
vector<pair<int, int>> yi(n);
vector<Coord> coords(n);
for (int i = 0; i < n; i++) {
coords[i] = {x[i], y[i], i};
}
sort(coords.begin(), coords.end());
bool res = true;
for (int i = 0; i < n-1; i++) {
if (coords[i].y+2 < coords[i+1].y) res = false;
if (coords[i].x == coords[i+1].x) {
u.pb(coords[i].i);
v.pb(coords[i+1].i);
a.pb(coords[i].x+1);
b.pb(coords[i].y+1);
} else if (coords[i].y == coords[i+1].y) {
u.pb(coords[i].i);
v.pb(coords[i+1].i);
a.pb(coords[i].x+1);
b.pb(coords[i].y-1);
}
// res &= yi[i].first+2 == yi[i+1].first;
// u.pb(yi[i].second);
// v.pb(yi[i+1].second);
// a.pb(3);
// b.pb(yi[i].first+1);
}
if (!res) return 0;
// int maxY = 0;
// for (int i = 0; i < y.size(); i++) maxY = max(maxY, y[i]);
// vvi mat(maxY/2-1, vi(3)), matIdx(maxY/2-1, vi(3));
// for (int i = 0; i < x.size(); i++) {
// mat[x[i]/2-1][y[i]/2-1] = 1;
// matIdx[x[i]/2-1][y[i]/2-1] = i;
// }
build(u, v, a, b);
return 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
296 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
296 KB |
Output is correct |
6 |
Correct |
1 ms |
284 KB |
Output is correct |
7 |
Correct |
1 ms |
300 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
54 ms |
9376 KB |
Output is correct |
10 |
Correct |
6 ms |
1364 KB |
Output is correct |
11 |
Correct |
27 ms |
5320 KB |
Output is correct |
12 |
Correct |
8 ms |
1700 KB |
Output is correct |
13 |
Correct |
8 ms |
3028 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
56 ms |
9500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
296 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
296 KB |
Output is correct |
6 |
Correct |
1 ms |
284 KB |
Output is correct |
7 |
Correct |
1 ms |
300 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
54 ms |
9376 KB |
Output is correct |
10 |
Correct |
6 ms |
1364 KB |
Output is correct |
11 |
Correct |
27 ms |
5320 KB |
Output is correct |
12 |
Correct |
8 ms |
1700 KB |
Output is correct |
13 |
Correct |
8 ms |
3028 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
56 ms |
9500 KB |
Output is correct |
17 |
Incorrect |
1 ms |
212 KB |
Given structure is not connected: There is no path between vertices 0 and 2 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
296 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
296 KB |
Output is correct |
6 |
Correct |
1 ms |
284 KB |
Output is correct |
7 |
Correct |
1 ms |
300 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
54 ms |
9376 KB |
Output is correct |
10 |
Correct |
6 ms |
1364 KB |
Output is correct |
11 |
Correct |
27 ms |
5320 KB |
Output is correct |
12 |
Correct |
8 ms |
1700 KB |
Output is correct |
13 |
Correct |
8 ms |
3028 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
56 ms |
9500 KB |
Output is correct |
17 |
Incorrect |
1 ms |
212 KB |
Given structure is not connected: There is no path between vertices 0 and 2 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
296 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
296 KB |
Output is correct |
6 |
Correct |
1 ms |
284 KB |
Output is correct |
7 |
Correct |
1 ms |
300 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
54 ms |
9376 KB |
Output is correct |
10 |
Correct |
6 ms |
1364 KB |
Output is correct |
11 |
Correct |
27 ms |
5320 KB |
Output is correct |
12 |
Correct |
8 ms |
1700 KB |
Output is correct |
13 |
Correct |
8 ms |
3028 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
56 ms |
9500 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Incorrect |
1 ms |
212 KB |
Given structure is not connected: There is no path between vertices 0 and 1 |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
296 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
296 KB |
Output is correct |
6 |
Correct |
1 ms |
284 KB |
Output is correct |
7 |
Correct |
1 ms |
300 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
54 ms |
9376 KB |
Output is correct |
10 |
Correct |
6 ms |
1364 KB |
Output is correct |
11 |
Correct |
27 ms |
5320 KB |
Output is correct |
12 |
Correct |
8 ms |
1700 KB |
Output is correct |
13 |
Correct |
8 ms |
3028 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
56 ms |
9500 KB |
Output is correct |
17 |
Incorrect |
103 ms |
16504 KB |
Pair u[50000]=112394 @(2, 4) and v[50000]=87394 @(100002, 4) does not form a valid edge (distance != 2) |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
296 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
296 KB |
Output is correct |
6 |
Correct |
1 ms |
284 KB |
Output is correct |
7 |
Correct |
1 ms |
300 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
54 ms |
9376 KB |
Output is correct |
10 |
Correct |
6 ms |
1364 KB |
Output is correct |
11 |
Correct |
27 ms |
5320 KB |
Output is correct |
12 |
Correct |
8 ms |
1700 KB |
Output is correct |
13 |
Correct |
8 ms |
3028 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
56 ms |
9500 KB |
Output is correct |
17 |
Incorrect |
1 ms |
212 KB |
Given structure is not connected: There is no path between vertices 0 and 2 |
18 |
Halted |
0 ms |
0 KB |
- |