Submission #691443

# Submission time Handle Problem Language Result Execution time Memory
691443 2023-01-31T07:15:47 Z Sohsoh84 Drawing (CEOI22_drawing) C++17
100 / 100
260 ms 53328 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

#define all(x)			(x).begin(),(x).end()
#define X			first
#define Y			second
#define sep			' '
#define endl			'\n'
#define debug(x)		cerr << #x << ": " <<  x << endl;

const ll MAXN = 1e6 + 10;

int n, sz = 0, ans[MAXN];
pair<pll, int> A[MAXN];
vector<int> vec, adj[MAXN];

inline ll Cross(pll x, pll y) {
	return 1ll * x.X * y.Y - 1ll * x.Y * y.X;
}
 
inline bool cmp(int i, int j) {
	return Cross(make_pair(A[0].X.X - A[i].X.X, A[0].X.Y - A[i].X.Y), 
			make_pair(A[0].X.X - A[j].X.X, A[0].X.Y - A[j].X.Y)) < 0;
}

void dfs(int v, int p, int l) {
	ans[l] = v;
	for (int u : adj[v])
		if (u != p)
			dfs(u, v, A[vec[sz++]].Y);
} 

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	for (int i = 0; i < n; i++) {
		ll x, y;
		cin >> x >> y;
		A[i] = {{x, y}, i};
	}	

	for (int i = 1; i < n; i++)
		vec.push_back(i);

	sort(all(vec), cmp);
	dfs(1, 0, 0);

	for (int i = 0; i < n; i++)
		cout << ans[i] << sep;
	cout << endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 106 ms 35148 KB Output is correct
2 Correct 112 ms 38472 KB Output is correct
3 Correct 109 ms 37024 KB Output is correct
4 Correct 125 ms 40268 KB Output is correct
5 Correct 114 ms 39604 KB Output is correct
6 Correct 102 ms 35196 KB Output is correct
7 Correct 126 ms 35788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 24140 KB Output is correct
2 Correct 15 ms 24316 KB Output is correct
3 Correct 16 ms 24264 KB Output is correct
4 Correct 15 ms 24276 KB Output is correct
5 Correct 16 ms 24348 KB Output is correct
6 Correct 15 ms 24212 KB Output is correct
7 Correct 15 ms 24272 KB Output is correct
8 Correct 16 ms 24208 KB Output is correct
9 Correct 15 ms 24340 KB Output is correct
10 Correct 15 ms 24268 KB Output is correct
11 Correct 15 ms 24276 KB Output is correct
12 Correct 15 ms 24212 KB Output is correct
13 Correct 15 ms 24208 KB Output is correct
14 Correct 15 ms 24276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 24140 KB Output is correct
2 Correct 15 ms 24316 KB Output is correct
3 Correct 16 ms 24264 KB Output is correct
4 Correct 15 ms 24276 KB Output is correct
5 Correct 16 ms 24348 KB Output is correct
6 Correct 15 ms 24212 KB Output is correct
7 Correct 15 ms 24272 KB Output is correct
8 Correct 16 ms 24208 KB Output is correct
9 Correct 15 ms 24340 KB Output is correct
10 Correct 15 ms 24268 KB Output is correct
11 Correct 15 ms 24276 KB Output is correct
12 Correct 15 ms 24212 KB Output is correct
13 Correct 15 ms 24208 KB Output is correct
14 Correct 15 ms 24276 KB Output is correct
15 Correct 18 ms 24788 KB Output is correct
16 Correct 18 ms 25016 KB Output is correct
17 Correct 20 ms 24852 KB Output is correct
18 Correct 19 ms 25128 KB Output is correct
19 Correct 19 ms 25172 KB Output is correct
20 Correct 19 ms 24788 KB Output is correct
21 Correct 20 ms 24940 KB Output is correct
22 Correct 19 ms 24804 KB Output is correct
23 Correct 18 ms 24980 KB Output is correct
24 Correct 19 ms 24864 KB Output is correct
25 Correct 19 ms 25264 KB Output is correct
26 Correct 19 ms 25104 KB Output is correct
27 Correct 20 ms 24748 KB Output is correct
28 Correct 19 ms 24976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 24140 KB Output is correct
2 Correct 15 ms 24316 KB Output is correct
3 Correct 16 ms 24264 KB Output is correct
4 Correct 15 ms 24276 KB Output is correct
5 Correct 16 ms 24348 KB Output is correct
6 Correct 15 ms 24212 KB Output is correct
7 Correct 15 ms 24272 KB Output is correct
8 Correct 16 ms 24208 KB Output is correct
9 Correct 15 ms 24340 KB Output is correct
10 Correct 15 ms 24268 KB Output is correct
11 Correct 15 ms 24276 KB Output is correct
12 Correct 15 ms 24212 KB Output is correct
13 Correct 15 ms 24208 KB Output is correct
14 Correct 15 ms 24276 KB Output is correct
15 Correct 18 ms 24788 KB Output is correct
16 Correct 18 ms 25016 KB Output is correct
17 Correct 20 ms 24852 KB Output is correct
18 Correct 19 ms 25128 KB Output is correct
19 Correct 19 ms 25172 KB Output is correct
20 Correct 19 ms 24788 KB Output is correct
21 Correct 20 ms 24940 KB Output is correct
22 Correct 19 ms 24804 KB Output is correct
23 Correct 18 ms 24980 KB Output is correct
24 Correct 19 ms 24864 KB Output is correct
25 Correct 19 ms 25264 KB Output is correct
26 Correct 19 ms 25104 KB Output is correct
27 Correct 20 ms 24748 KB Output is correct
28 Correct 19 ms 24976 KB Output is correct
29 Correct 76 ms 31860 KB Output is correct
30 Correct 85 ms 34176 KB Output is correct
31 Correct 73 ms 33300 KB Output is correct
32 Correct 77 ms 34932 KB Output is correct
33 Correct 81 ms 34428 KB Output is correct
34 Correct 84 ms 31872 KB Output is correct
35 Correct 86 ms 32508 KB Output is correct
36 Correct 67 ms 30720 KB Output is correct
37 Correct 76 ms 33472 KB Output is correct
38 Correct 73 ms 33668 KB Output is correct
39 Correct 79 ms 34440 KB Output is correct
40 Correct 73 ms 33416 KB Output is correct
41 Correct 65 ms 30880 KB Output is correct
42 Correct 94 ms 32564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 106 ms 35148 KB Output is correct
2 Correct 112 ms 38472 KB Output is correct
3 Correct 109 ms 37024 KB Output is correct
4 Correct 125 ms 40268 KB Output is correct
5 Correct 114 ms 39604 KB Output is correct
6 Correct 102 ms 35196 KB Output is correct
7 Correct 126 ms 35788 KB Output is correct
8 Correct 14 ms 24140 KB Output is correct
9 Correct 15 ms 24316 KB Output is correct
10 Correct 16 ms 24264 KB Output is correct
11 Correct 15 ms 24276 KB Output is correct
12 Correct 16 ms 24348 KB Output is correct
13 Correct 15 ms 24212 KB Output is correct
14 Correct 15 ms 24272 KB Output is correct
15 Correct 16 ms 24208 KB Output is correct
16 Correct 15 ms 24340 KB Output is correct
17 Correct 15 ms 24268 KB Output is correct
18 Correct 15 ms 24276 KB Output is correct
19 Correct 15 ms 24212 KB Output is correct
20 Correct 15 ms 24208 KB Output is correct
21 Correct 15 ms 24276 KB Output is correct
22 Correct 18 ms 24788 KB Output is correct
23 Correct 18 ms 25016 KB Output is correct
24 Correct 20 ms 24852 KB Output is correct
25 Correct 19 ms 25128 KB Output is correct
26 Correct 19 ms 25172 KB Output is correct
27 Correct 19 ms 24788 KB Output is correct
28 Correct 20 ms 24940 KB Output is correct
29 Correct 19 ms 24804 KB Output is correct
30 Correct 18 ms 24980 KB Output is correct
31 Correct 19 ms 24864 KB Output is correct
32 Correct 19 ms 25264 KB Output is correct
33 Correct 19 ms 25104 KB Output is correct
34 Correct 20 ms 24748 KB Output is correct
35 Correct 19 ms 24976 KB Output is correct
36 Correct 76 ms 31860 KB Output is correct
37 Correct 85 ms 34176 KB Output is correct
38 Correct 73 ms 33300 KB Output is correct
39 Correct 77 ms 34932 KB Output is correct
40 Correct 81 ms 34428 KB Output is correct
41 Correct 84 ms 31872 KB Output is correct
42 Correct 86 ms 32508 KB Output is correct
43 Correct 67 ms 30720 KB Output is correct
44 Correct 76 ms 33472 KB Output is correct
45 Correct 73 ms 33668 KB Output is correct
46 Correct 79 ms 34440 KB Output is correct
47 Correct 73 ms 33416 KB Output is correct
48 Correct 65 ms 30880 KB Output is correct
49 Correct 94 ms 32564 KB Output is correct
50 Correct 141 ms 36348 KB Output is correct
51 Correct 238 ms 49732 KB Output is correct
52 Correct 228 ms 47680 KB Output is correct
53 Correct 253 ms 49588 KB Output is correct
54 Correct 218 ms 53328 KB Output is correct
55 Correct 206 ms 44140 KB Output is correct
56 Correct 251 ms 45140 KB Output is correct
57 Correct 42 ms 28108 KB Output is correct
58 Correct 222 ms 47444 KB Output is correct
59 Correct 206 ms 46936 KB Output is correct
60 Correct 242 ms 52772 KB Output is correct
61 Correct 260 ms 48716 KB Output is correct
62 Correct 45 ms 28120 KB Output is correct
63 Correct 245 ms 45056 KB Output is correct