#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef long long llint;
const int maxn = 1e6+10;
const int base = 31337;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int logo = 20;
const int off = 1 << logo;
const int treesiz = off << 1;
int n;
vector< int > graph[maxn];
pair< pair<int, int>, int > niz[maxn];
int sol[maxn];
llint ccw(pair<int, int> a, pair<int, int> b, pair<int, int> c) {
return (llint)a.X * (b.Y - c.Y) + (llint)b.X * (c.Y - a.Y) + (llint)c.X * (a.Y - b.Y);
}
bool cmp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
return ccw(niz[0].X, a.X, b.X) >= 0;
}
int t = 0;
void solve(int x, int parr) {
//printf("solve: %d\n", x);
sol[x] = niz[t++].Y;
for (int tren : graph[x]) {
if (tren == parr) continue;
solve(tren, x);
}
}
int main() {
scanf("%d", &n);
for (int i = 1; i < n; i++) {
int a, b;
scanf("%d%d", &a, &b);
graph[a].push_back(b);
graph[b].push_back(a);
}
for (int i = 0; i < n; i++) {
int x, y;
scanf("%d%d", &x, &y);
niz[i] = {{x, y}, i + 1};
}
sort(niz, niz+n);
sort(niz+1, niz+n, cmp);
//for (int i = 0; i < n; i++)
// printf("%d %d -- %d\n", niz[i].X.X, niz[i].X.Y, niz[i].Y);
solve(1, 0);
for (int i = 1; i <= n; i++) printf("%d ", sol[i]);
printf("\n");
return 0;
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:40:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
40 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
Main.cpp:43:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
43 | scanf("%d%d", &a, &b);
| ~~~~~^~~~~~~~~~~~~~~~
Main.cpp:50:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
50 | scanf("%d%d", &x, &y);
| ~~~~~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
119 ms |
29856 KB |
Output is correct |
2 |
Correct |
129 ms |
33016 KB |
Output is correct |
3 |
Correct |
120 ms |
31540 KB |
Output is correct |
4 |
Correct |
138 ms |
34248 KB |
Output is correct |
5 |
Correct |
114 ms |
34352 KB |
Output is correct |
6 |
Correct |
118 ms |
29740 KB |
Output is correct |
7 |
Correct |
137 ms |
30248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
23892 KB |
Output is correct |
2 |
Correct |
16 ms |
24048 KB |
Output is correct |
3 |
Correct |
15 ms |
24020 KB |
Output is correct |
4 |
Correct |
18 ms |
24068 KB |
Output is correct |
5 |
Correct |
16 ms |
24148 KB |
Output is correct |
6 |
Correct |
18 ms |
24004 KB |
Output is correct |
7 |
Correct |
16 ms |
23936 KB |
Output is correct |
8 |
Correct |
16 ms |
23892 KB |
Output is correct |
9 |
Correct |
15 ms |
24112 KB |
Output is correct |
10 |
Correct |
16 ms |
24072 KB |
Output is correct |
11 |
Correct |
16 ms |
24156 KB |
Output is correct |
12 |
Correct |
15 ms |
24020 KB |
Output is correct |
13 |
Correct |
16 ms |
23940 KB |
Output is correct |
14 |
Correct |
15 ms |
24020 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
23892 KB |
Output is correct |
2 |
Correct |
16 ms |
24048 KB |
Output is correct |
3 |
Correct |
15 ms |
24020 KB |
Output is correct |
4 |
Correct |
18 ms |
24068 KB |
Output is correct |
5 |
Correct |
16 ms |
24148 KB |
Output is correct |
6 |
Correct |
18 ms |
24004 KB |
Output is correct |
7 |
Correct |
16 ms |
23936 KB |
Output is correct |
8 |
Correct |
16 ms |
23892 KB |
Output is correct |
9 |
Correct |
15 ms |
24112 KB |
Output is correct |
10 |
Correct |
16 ms |
24072 KB |
Output is correct |
11 |
Correct |
16 ms |
24156 KB |
Output is correct |
12 |
Correct |
15 ms |
24020 KB |
Output is correct |
13 |
Correct |
16 ms |
23940 KB |
Output is correct |
14 |
Correct |
15 ms |
24020 KB |
Output is correct |
15 |
Correct |
20 ms |
24260 KB |
Output is correct |
16 |
Correct |
20 ms |
24532 KB |
Output is correct |
17 |
Correct |
21 ms |
24308 KB |
Output is correct |
18 |
Correct |
22 ms |
24712 KB |
Output is correct |
19 |
Correct |
21 ms |
24692 KB |
Output is correct |
20 |
Correct |
20 ms |
24276 KB |
Output is correct |
21 |
Correct |
20 ms |
24368 KB |
Output is correct |
22 |
Correct |
21 ms |
24276 KB |
Output is correct |
23 |
Correct |
20 ms |
24424 KB |
Output is correct |
24 |
Correct |
20 ms |
24404 KB |
Output is correct |
25 |
Correct |
20 ms |
24744 KB |
Output is correct |
26 |
Correct |
20 ms |
24660 KB |
Output is correct |
27 |
Correct |
20 ms |
24260 KB |
Output is correct |
28 |
Correct |
20 ms |
24308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
23892 KB |
Output is correct |
2 |
Correct |
16 ms |
24048 KB |
Output is correct |
3 |
Correct |
15 ms |
24020 KB |
Output is correct |
4 |
Correct |
18 ms |
24068 KB |
Output is correct |
5 |
Correct |
16 ms |
24148 KB |
Output is correct |
6 |
Correct |
18 ms |
24004 KB |
Output is correct |
7 |
Correct |
16 ms |
23936 KB |
Output is correct |
8 |
Correct |
16 ms |
23892 KB |
Output is correct |
9 |
Correct |
15 ms |
24112 KB |
Output is correct |
10 |
Correct |
16 ms |
24072 KB |
Output is correct |
11 |
Correct |
16 ms |
24156 KB |
Output is correct |
12 |
Correct |
15 ms |
24020 KB |
Output is correct |
13 |
Correct |
16 ms |
23940 KB |
Output is correct |
14 |
Correct |
15 ms |
24020 KB |
Output is correct |
15 |
Correct |
20 ms |
24260 KB |
Output is correct |
16 |
Correct |
20 ms |
24532 KB |
Output is correct |
17 |
Correct |
21 ms |
24308 KB |
Output is correct |
18 |
Correct |
22 ms |
24712 KB |
Output is correct |
19 |
Correct |
21 ms |
24692 KB |
Output is correct |
20 |
Correct |
20 ms |
24276 KB |
Output is correct |
21 |
Correct |
20 ms |
24368 KB |
Output is correct |
22 |
Correct |
21 ms |
24276 KB |
Output is correct |
23 |
Correct |
20 ms |
24424 KB |
Output is correct |
24 |
Correct |
20 ms |
24404 KB |
Output is correct |
25 |
Correct |
20 ms |
24744 KB |
Output is correct |
26 |
Correct |
20 ms |
24660 KB |
Output is correct |
27 |
Correct |
20 ms |
24260 KB |
Output is correct |
28 |
Correct |
20 ms |
24308 KB |
Output is correct |
29 |
Correct |
80 ms |
27968 KB |
Output is correct |
30 |
Correct |
88 ms |
30284 KB |
Output is correct |
31 |
Correct |
90 ms |
29408 KB |
Output is correct |
32 |
Correct |
88 ms |
31396 KB |
Output is correct |
33 |
Correct |
90 ms |
30556 KB |
Output is correct |
34 |
Correct |
82 ms |
27980 KB |
Output is correct |
35 |
Correct |
85 ms |
28528 KB |
Output is correct |
36 |
Correct |
80 ms |
27380 KB |
Output is correct |
37 |
Correct |
89 ms |
29620 KB |
Output is correct |
38 |
Correct |
84 ms |
29700 KB |
Output is correct |
39 |
Correct |
87 ms |
30556 KB |
Output is correct |
40 |
Correct |
87 ms |
29916 KB |
Output is correct |
41 |
Correct |
76 ms |
27416 KB |
Output is correct |
42 |
Correct |
89 ms |
28572 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
119 ms |
29856 KB |
Output is correct |
2 |
Correct |
129 ms |
33016 KB |
Output is correct |
3 |
Correct |
120 ms |
31540 KB |
Output is correct |
4 |
Correct |
138 ms |
34248 KB |
Output is correct |
5 |
Correct |
114 ms |
34352 KB |
Output is correct |
6 |
Correct |
118 ms |
29740 KB |
Output is correct |
7 |
Correct |
137 ms |
30248 KB |
Output is correct |
8 |
Correct |
15 ms |
23892 KB |
Output is correct |
9 |
Correct |
16 ms |
24048 KB |
Output is correct |
10 |
Correct |
15 ms |
24020 KB |
Output is correct |
11 |
Correct |
18 ms |
24068 KB |
Output is correct |
12 |
Correct |
16 ms |
24148 KB |
Output is correct |
13 |
Correct |
18 ms |
24004 KB |
Output is correct |
14 |
Correct |
16 ms |
23936 KB |
Output is correct |
15 |
Correct |
16 ms |
23892 KB |
Output is correct |
16 |
Correct |
15 ms |
24112 KB |
Output is correct |
17 |
Correct |
16 ms |
24072 KB |
Output is correct |
18 |
Correct |
16 ms |
24156 KB |
Output is correct |
19 |
Correct |
15 ms |
24020 KB |
Output is correct |
20 |
Correct |
16 ms |
23940 KB |
Output is correct |
21 |
Correct |
15 ms |
24020 KB |
Output is correct |
22 |
Correct |
20 ms |
24260 KB |
Output is correct |
23 |
Correct |
20 ms |
24532 KB |
Output is correct |
24 |
Correct |
21 ms |
24308 KB |
Output is correct |
25 |
Correct |
22 ms |
24712 KB |
Output is correct |
26 |
Correct |
21 ms |
24692 KB |
Output is correct |
27 |
Correct |
20 ms |
24276 KB |
Output is correct |
28 |
Correct |
20 ms |
24368 KB |
Output is correct |
29 |
Correct |
21 ms |
24276 KB |
Output is correct |
30 |
Correct |
20 ms |
24424 KB |
Output is correct |
31 |
Correct |
20 ms |
24404 KB |
Output is correct |
32 |
Correct |
20 ms |
24744 KB |
Output is correct |
33 |
Correct |
20 ms |
24660 KB |
Output is correct |
34 |
Correct |
20 ms |
24260 KB |
Output is correct |
35 |
Correct |
20 ms |
24308 KB |
Output is correct |
36 |
Correct |
80 ms |
27968 KB |
Output is correct |
37 |
Correct |
88 ms |
30284 KB |
Output is correct |
38 |
Correct |
90 ms |
29408 KB |
Output is correct |
39 |
Correct |
88 ms |
31396 KB |
Output is correct |
40 |
Correct |
90 ms |
30556 KB |
Output is correct |
41 |
Correct |
82 ms |
27980 KB |
Output is correct |
42 |
Correct |
85 ms |
28528 KB |
Output is correct |
43 |
Correct |
80 ms |
27380 KB |
Output is correct |
44 |
Correct |
89 ms |
29620 KB |
Output is correct |
45 |
Correct |
84 ms |
29700 KB |
Output is correct |
46 |
Correct |
87 ms |
30556 KB |
Output is correct |
47 |
Correct |
87 ms |
29916 KB |
Output is correct |
48 |
Correct |
76 ms |
27416 KB |
Output is correct |
49 |
Correct |
89 ms |
28572 KB |
Output is correct |
50 |
Correct |
163 ms |
30436 KB |
Output is correct |
51 |
Correct |
243 ms |
40072 KB |
Output is correct |
52 |
Correct |
253 ms |
37812 KB |
Output is correct |
53 |
Correct |
248 ms |
40636 KB |
Output is correct |
54 |
Correct |
252 ms |
43704 KB |
Output is correct |
55 |
Correct |
252 ms |
34440 KB |
Output is correct |
56 |
Correct |
237 ms |
35448 KB |
Output is correct |
57 |
Correct |
54 ms |
26032 KB |
Output is correct |
58 |
Correct |
256 ms |
37724 KB |
Output is correct |
59 |
Correct |
236 ms |
37264 KB |
Output is correct |
60 |
Correct |
255 ms |
42976 KB |
Output is correct |
61 |
Correct |
257 ms |
39680 KB |
Output is correct |
62 |
Correct |
59 ms |
25988 KB |
Output is correct |
63 |
Correct |
233 ms |
35328 KB |
Output is correct |