// CEOI 2022 Day2 Drawing
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
struct Point {
int x, y, id;
bool operator<(const Point& p) const {
if (x != p.x) return x < p.x;
return y < p.y;
}
};
LL cross(const Point& a, const Point& b, const Point& c) {
return (LL)a.x * (b.y - c.y) + (LL)b.x * (c.y - a.y) + (LL)c.x * (a.y - b.y);
}
int main() {
ios::sync_with_stdio(false), cin.tie(0);
int N;
cin >> N;
vector<vector<int>> G(N + 1);
for (int i = 1, a, b; i < N; i++)
cin >> a >> b, G[a].push_back(b), G[b].push_back(a);
vector<Point> ps(N);
for (int i = 0; i < N; i++) cin >> ps[i].x >> ps[i].y, ps[i].id = i + 1;
sort(begin(ps), end(ps));
sort(begin(ps) + 1, end(ps),
[&](const Point& a, const Point& b) { return cross(ps[0], a, b) >= 0; });
int pi = 0;
vector<int> Ans(N + 1);
function<void(int, int)> dfs = [&](int u, int fa) {
Ans[u] = ps[pi++].id;
for (int v : G[u])
if (v != fa) dfs(v, u);
};
dfs(1, 0);
for (int i = 1; i <= N; i++) printf("%d ", Ans[i]);
puts("");
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
93 ms |
12416 KB |
Output is correct |
2 |
Correct |
103 ms |
17716 KB |
Output is correct |
3 |
Correct |
99 ms |
15420 KB |
Output is correct |
4 |
Correct |
116 ms |
19648 KB |
Output is correct |
5 |
Correct |
101 ms |
20084 KB |
Output is correct |
6 |
Correct |
91 ms |
12308 KB |
Output is correct |
7 |
Correct |
100 ms |
13268 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
704 KB |
Output is correct |
2 |
Correct |
3 ms |
824 KB |
Output is correct |
3 |
Correct |
3 ms |
708 KB |
Output is correct |
4 |
Correct |
3 ms |
936 KB |
Output is correct |
5 |
Correct |
3 ms |
980 KB |
Output is correct |
6 |
Correct |
3 ms |
724 KB |
Output is correct |
7 |
Correct |
3 ms |
712 KB |
Output is correct |
8 |
Correct |
3 ms |
724 KB |
Output is correct |
9 |
Correct |
4 ms |
852 KB |
Output is correct |
10 |
Correct |
4 ms |
724 KB |
Output is correct |
11 |
Correct |
3 ms |
972 KB |
Output is correct |
12 |
Correct |
3 ms |
852 KB |
Output is correct |
13 |
Correct |
4 ms |
712 KB |
Output is correct |
14 |
Correct |
5 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
704 KB |
Output is correct |
2 |
Correct |
3 ms |
824 KB |
Output is correct |
3 |
Correct |
3 ms |
708 KB |
Output is correct |
4 |
Correct |
3 ms |
936 KB |
Output is correct |
5 |
Correct |
3 ms |
980 KB |
Output is correct |
6 |
Correct |
3 ms |
724 KB |
Output is correct |
7 |
Correct |
3 ms |
712 KB |
Output is correct |
8 |
Correct |
3 ms |
724 KB |
Output is correct |
9 |
Correct |
4 ms |
852 KB |
Output is correct |
10 |
Correct |
4 ms |
724 KB |
Output is correct |
11 |
Correct |
3 ms |
972 KB |
Output is correct |
12 |
Correct |
3 ms |
852 KB |
Output is correct |
13 |
Correct |
4 ms |
712 KB |
Output is correct |
14 |
Correct |
5 ms |
724 KB |
Output is correct |
15 |
Correct |
9 ms |
1364 KB |
Output is correct |
16 |
Correct |
8 ms |
1748 KB |
Output is correct |
17 |
Correct |
7 ms |
1488 KB |
Output is correct |
18 |
Correct |
8 ms |
2004 KB |
Output is correct |
19 |
Correct |
8 ms |
2004 KB |
Output is correct |
20 |
Correct |
7 ms |
1284 KB |
Output is correct |
21 |
Correct |
8 ms |
1524 KB |
Output is correct |
22 |
Correct |
8 ms |
1364 KB |
Output is correct |
23 |
Correct |
8 ms |
1620 KB |
Output is correct |
24 |
Correct |
11 ms |
1584 KB |
Output is correct |
25 |
Correct |
8 ms |
2004 KB |
Output is correct |
26 |
Correct |
7 ms |
1876 KB |
Output is correct |
27 |
Correct |
7 ms |
1288 KB |
Output is correct |
28 |
Correct |
8 ms |
1536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
704 KB |
Output is correct |
2 |
Correct |
3 ms |
824 KB |
Output is correct |
3 |
Correct |
3 ms |
708 KB |
Output is correct |
4 |
Correct |
3 ms |
936 KB |
Output is correct |
5 |
Correct |
3 ms |
980 KB |
Output is correct |
6 |
Correct |
3 ms |
724 KB |
Output is correct |
7 |
Correct |
3 ms |
712 KB |
Output is correct |
8 |
Correct |
3 ms |
724 KB |
Output is correct |
9 |
Correct |
4 ms |
852 KB |
Output is correct |
10 |
Correct |
4 ms |
724 KB |
Output is correct |
11 |
Correct |
3 ms |
972 KB |
Output is correct |
12 |
Correct |
3 ms |
852 KB |
Output is correct |
13 |
Correct |
4 ms |
712 KB |
Output is correct |
14 |
Correct |
5 ms |
724 KB |
Output is correct |
15 |
Correct |
9 ms |
1364 KB |
Output is correct |
16 |
Correct |
8 ms |
1748 KB |
Output is correct |
17 |
Correct |
7 ms |
1488 KB |
Output is correct |
18 |
Correct |
8 ms |
2004 KB |
Output is correct |
19 |
Correct |
8 ms |
2004 KB |
Output is correct |
20 |
Correct |
7 ms |
1284 KB |
Output is correct |
21 |
Correct |
8 ms |
1524 KB |
Output is correct |
22 |
Correct |
8 ms |
1364 KB |
Output is correct |
23 |
Correct |
8 ms |
1620 KB |
Output is correct |
24 |
Correct |
11 ms |
1584 KB |
Output is correct |
25 |
Correct |
8 ms |
2004 KB |
Output is correct |
26 |
Correct |
7 ms |
1876 KB |
Output is correct |
27 |
Correct |
7 ms |
1288 KB |
Output is correct |
28 |
Correct |
8 ms |
1536 KB |
Output is correct |
29 |
Correct |
64 ms |
8728 KB |
Output is correct |
30 |
Correct |
69 ms |
12748 KB |
Output is correct |
31 |
Correct |
66 ms |
11264 KB |
Output is correct |
32 |
Correct |
68 ms |
14200 KB |
Output is correct |
33 |
Correct |
79 ms |
13236 KB |
Output is correct |
34 |
Correct |
64 ms |
8780 KB |
Output is correct |
35 |
Correct |
66 ms |
9840 KB |
Output is correct |
36 |
Correct |
61 ms |
7680 KB |
Output is correct |
37 |
Correct |
69 ms |
11608 KB |
Output is correct |
38 |
Correct |
76 ms |
11756 KB |
Output is correct |
39 |
Correct |
67 ms |
13120 KB |
Output is correct |
40 |
Correct |
64 ms |
11624 KB |
Output is correct |
41 |
Correct |
59 ms |
7648 KB |
Output is correct |
42 |
Correct |
63 ms |
9908 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
93 ms |
12416 KB |
Output is correct |
2 |
Correct |
103 ms |
17716 KB |
Output is correct |
3 |
Correct |
99 ms |
15420 KB |
Output is correct |
4 |
Correct |
116 ms |
19648 KB |
Output is correct |
5 |
Correct |
101 ms |
20084 KB |
Output is correct |
6 |
Correct |
91 ms |
12308 KB |
Output is correct |
7 |
Correct |
100 ms |
13268 KB |
Output is correct |
8 |
Correct |
5 ms |
704 KB |
Output is correct |
9 |
Correct |
3 ms |
824 KB |
Output is correct |
10 |
Correct |
3 ms |
708 KB |
Output is correct |
11 |
Correct |
3 ms |
936 KB |
Output is correct |
12 |
Correct |
3 ms |
980 KB |
Output is correct |
13 |
Correct |
3 ms |
724 KB |
Output is correct |
14 |
Correct |
3 ms |
712 KB |
Output is correct |
15 |
Correct |
3 ms |
724 KB |
Output is correct |
16 |
Correct |
4 ms |
852 KB |
Output is correct |
17 |
Correct |
4 ms |
724 KB |
Output is correct |
18 |
Correct |
3 ms |
972 KB |
Output is correct |
19 |
Correct |
3 ms |
852 KB |
Output is correct |
20 |
Correct |
4 ms |
712 KB |
Output is correct |
21 |
Correct |
5 ms |
724 KB |
Output is correct |
22 |
Correct |
9 ms |
1364 KB |
Output is correct |
23 |
Correct |
8 ms |
1748 KB |
Output is correct |
24 |
Correct |
7 ms |
1488 KB |
Output is correct |
25 |
Correct |
8 ms |
2004 KB |
Output is correct |
26 |
Correct |
8 ms |
2004 KB |
Output is correct |
27 |
Correct |
7 ms |
1284 KB |
Output is correct |
28 |
Correct |
8 ms |
1524 KB |
Output is correct |
29 |
Correct |
8 ms |
1364 KB |
Output is correct |
30 |
Correct |
8 ms |
1620 KB |
Output is correct |
31 |
Correct |
11 ms |
1584 KB |
Output is correct |
32 |
Correct |
8 ms |
2004 KB |
Output is correct |
33 |
Correct |
7 ms |
1876 KB |
Output is correct |
34 |
Correct |
7 ms |
1288 KB |
Output is correct |
35 |
Correct |
8 ms |
1536 KB |
Output is correct |
36 |
Correct |
64 ms |
8728 KB |
Output is correct |
37 |
Correct |
69 ms |
12748 KB |
Output is correct |
38 |
Correct |
66 ms |
11264 KB |
Output is correct |
39 |
Correct |
68 ms |
14200 KB |
Output is correct |
40 |
Correct |
79 ms |
13236 KB |
Output is correct |
41 |
Correct |
64 ms |
8780 KB |
Output is correct |
42 |
Correct |
66 ms |
9840 KB |
Output is correct |
43 |
Correct |
61 ms |
7680 KB |
Output is correct |
44 |
Correct |
69 ms |
11608 KB |
Output is correct |
45 |
Correct |
76 ms |
11756 KB |
Output is correct |
46 |
Correct |
67 ms |
13120 KB |
Output is correct |
47 |
Correct |
64 ms |
11624 KB |
Output is correct |
48 |
Correct |
59 ms |
7648 KB |
Output is correct |
49 |
Correct |
63 ms |
9908 KB |
Output is correct |
50 |
Correct |
109 ms |
13320 KB |
Output is correct |
51 |
Correct |
218 ms |
28524 KB |
Output is correct |
52 |
Correct |
207 ms |
24812 KB |
Output is correct |
53 |
Correct |
217 ms |
29268 KB |
Output is correct |
54 |
Correct |
229 ms |
34572 KB |
Output is correct |
55 |
Correct |
212 ms |
19000 KB |
Output is correct |
56 |
Correct |
216 ms |
20764 KB |
Output is correct |
57 |
Correct |
33 ms |
4812 KB |
Output is correct |
58 |
Correct |
226 ms |
24592 KB |
Output is correct |
59 |
Correct |
208 ms |
23756 KB |
Output is correct |
60 |
Correct |
228 ms |
33348 KB |
Output is correct |
61 |
Correct |
215 ms |
27712 KB |
Output is correct |
62 |
Correct |
33 ms |
4812 KB |
Output is correct |
63 |
Correct |
207 ms |
20404 KB |
Output is correct |