답안 #799669

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
799669 2023-07-31T18:43:48 Z GusterGoose27 Drawing (CEOI22_drawing) C++17
100 / 100
162 ms 31332 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

struct point {
	int a, b;
	point() {}
	point(int a, int b) : a(a), b(b) {}
};

ll operator*(point a, point b) {
	return a.a*b.b-a.b*b.a;
}

point operator-(point a, point b) {
	return point(a.a-b.a, a.b-b.b);
}

point base;

bool operator<(point a, point b) {
	return (a-base)*(b-base) > 0;
}

typedef pair<int, int> pii;
typedef pair<point, int> ppi;

const int MAXN = 2e5+5;
int n;
ppi points[MAXN];
vector<int> edges[MAXN];
int nxt = 0;
int ans[MAXN];

void dfs(int cur, int p = -1) {
	ans[points[nxt++].second] = cur+1;
	for (int e: edges[cur]) {
		if (e == p) continue;
		dfs(e, cur);
	}
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin >> n;
	int lft = 0;
	for (int i = 0; i < n-1; i++) {
		int x, y; cin >> x >> y;
		x--; y--;
		edges[x].push_back(y);
		edges[y].push_back(x);
	}
	for (int i = 0; i < n; i++) {
		int x, y; cin >> x >> y;
		points[i] = ppi(point(x, y), i);
		if (pii(x, y) < pii(points[lft].first.a, points[lft].first.b)) lft = i;
	}
	swap(points[0], points[lft]);
	base = points[0].first;
	sort(points+1, points+n);
	dfs(0);
	for (int i = 0; i < n; i++) {
		if (i) cout << ' ';
		cout << ans[i];
	}
	cout << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 67 ms 15508 KB Output is correct
2 Correct 73 ms 18704 KB Output is correct
3 Correct 68 ms 17296 KB Output is correct
4 Correct 74 ms 20196 KB Output is correct
5 Correct 66 ms 20008 KB Output is correct
6 Correct 63 ms 15524 KB Output is correct
7 Correct 66 ms 15980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 7636 KB Output is correct
2 Correct 5 ms 7636 KB Output is correct
3 Correct 5 ms 7640 KB Output is correct
4 Correct 5 ms 7696 KB Output is correct
5 Correct 5 ms 7772 KB Output is correct
6 Correct 5 ms 7636 KB Output is correct
7 Correct 5 ms 7636 KB Output is correct
8 Correct 5 ms 7636 KB Output is correct
9 Correct 5 ms 7764 KB Output is correct
10 Correct 5 ms 7636 KB Output is correct
11 Correct 5 ms 7764 KB Output is correct
12 Correct 5 ms 7636 KB Output is correct
13 Correct 5 ms 7612 KB Output is correct
14 Correct 5 ms 7604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 7636 KB Output is correct
2 Correct 5 ms 7636 KB Output is correct
3 Correct 5 ms 7640 KB Output is correct
4 Correct 5 ms 7696 KB Output is correct
5 Correct 5 ms 7772 KB Output is correct
6 Correct 5 ms 7636 KB Output is correct
7 Correct 5 ms 7636 KB Output is correct
8 Correct 5 ms 7636 KB Output is correct
9 Correct 5 ms 7764 KB Output is correct
10 Correct 5 ms 7636 KB Output is correct
11 Correct 5 ms 7764 KB Output is correct
12 Correct 5 ms 7636 KB Output is correct
13 Correct 5 ms 7612 KB Output is correct
14 Correct 5 ms 7604 KB Output is correct
15 Correct 8 ms 8024 KB Output is correct
16 Correct 7 ms 8284 KB Output is correct
17 Correct 8 ms 8148 KB Output is correct
18 Correct 8 ms 8404 KB Output is correct
19 Correct 8 ms 8404 KB Output is correct
20 Correct 8 ms 8020 KB Output is correct
21 Correct 8 ms 8152 KB Output is correct
22 Correct 8 ms 8020 KB Output is correct
23 Correct 8 ms 8156 KB Output is correct
24 Correct 8 ms 8148 KB Output is correct
25 Correct 8 ms 8404 KB Output is correct
26 Correct 8 ms 8280 KB Output is correct
27 Correct 8 ms 7980 KB Output is correct
28 Correct 8 ms 8176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 7636 KB Output is correct
2 Correct 5 ms 7636 KB Output is correct
3 Correct 5 ms 7640 KB Output is correct
4 Correct 5 ms 7696 KB Output is correct
5 Correct 5 ms 7772 KB Output is correct
6 Correct 5 ms 7636 KB Output is correct
7 Correct 5 ms 7636 KB Output is correct
8 Correct 5 ms 7636 KB Output is correct
9 Correct 5 ms 7764 KB Output is correct
10 Correct 5 ms 7636 KB Output is correct
11 Correct 5 ms 7764 KB Output is correct
12 Correct 5 ms 7636 KB Output is correct
13 Correct 5 ms 7612 KB Output is correct
14 Correct 5 ms 7604 KB Output is correct
15 Correct 8 ms 8024 KB Output is correct
16 Correct 7 ms 8284 KB Output is correct
17 Correct 8 ms 8148 KB Output is correct
18 Correct 8 ms 8404 KB Output is correct
19 Correct 8 ms 8404 KB Output is correct
20 Correct 8 ms 8020 KB Output is correct
21 Correct 8 ms 8152 KB Output is correct
22 Correct 8 ms 8020 KB Output is correct
23 Correct 8 ms 8156 KB Output is correct
24 Correct 8 ms 8148 KB Output is correct
25 Correct 8 ms 8404 KB Output is correct
26 Correct 8 ms 8280 KB Output is correct
27 Correct 8 ms 7980 KB Output is correct
28 Correct 8 ms 8176 KB Output is correct
29 Correct 57 ms 13144 KB Output is correct
30 Correct 47 ms 15324 KB Output is correct
31 Correct 46 ms 14576 KB Output is correct
32 Correct 44 ms 16076 KB Output is correct
33 Correct 52 ms 15732 KB Output is correct
34 Correct 44 ms 13044 KB Output is correct
35 Correct 45 ms 13604 KB Output is correct
36 Correct 40 ms 12312 KB Output is correct
37 Correct 47 ms 14708 KB Output is correct
38 Correct 45 ms 14796 KB Output is correct
39 Correct 45 ms 15720 KB Output is correct
40 Correct 44 ms 14676 KB Output is correct
41 Correct 38 ms 12236 KB Output is correct
42 Correct 45 ms 13744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 67 ms 15508 KB Output is correct
2 Correct 73 ms 18704 KB Output is correct
3 Correct 68 ms 17296 KB Output is correct
4 Correct 74 ms 20196 KB Output is correct
5 Correct 66 ms 20008 KB Output is correct
6 Correct 63 ms 15524 KB Output is correct
7 Correct 66 ms 15980 KB Output is correct
8 Correct 5 ms 7636 KB Output is correct
9 Correct 5 ms 7636 KB Output is correct
10 Correct 5 ms 7640 KB Output is correct
11 Correct 5 ms 7696 KB Output is correct
12 Correct 5 ms 7772 KB Output is correct
13 Correct 5 ms 7636 KB Output is correct
14 Correct 5 ms 7636 KB Output is correct
15 Correct 5 ms 7636 KB Output is correct
16 Correct 5 ms 7764 KB Output is correct
17 Correct 5 ms 7636 KB Output is correct
18 Correct 5 ms 7764 KB Output is correct
19 Correct 5 ms 7636 KB Output is correct
20 Correct 5 ms 7612 KB Output is correct
21 Correct 5 ms 7604 KB Output is correct
22 Correct 8 ms 8024 KB Output is correct
23 Correct 7 ms 8284 KB Output is correct
24 Correct 8 ms 8148 KB Output is correct
25 Correct 8 ms 8404 KB Output is correct
26 Correct 8 ms 8404 KB Output is correct
27 Correct 8 ms 8020 KB Output is correct
28 Correct 8 ms 8152 KB Output is correct
29 Correct 8 ms 8020 KB Output is correct
30 Correct 8 ms 8156 KB Output is correct
31 Correct 8 ms 8148 KB Output is correct
32 Correct 8 ms 8404 KB Output is correct
33 Correct 8 ms 8280 KB Output is correct
34 Correct 8 ms 7980 KB Output is correct
35 Correct 8 ms 8176 KB Output is correct
36 Correct 57 ms 13144 KB Output is correct
37 Correct 47 ms 15324 KB Output is correct
38 Correct 46 ms 14576 KB Output is correct
39 Correct 44 ms 16076 KB Output is correct
40 Correct 52 ms 15732 KB Output is correct
41 Correct 44 ms 13044 KB Output is correct
42 Correct 45 ms 13604 KB Output is correct
43 Correct 40 ms 12312 KB Output is correct
44 Correct 47 ms 14708 KB Output is correct
45 Correct 45 ms 14796 KB Output is correct
46 Correct 45 ms 15720 KB Output is correct
47 Correct 44 ms 14676 KB Output is correct
48 Correct 38 ms 12236 KB Output is correct
49 Correct 45 ms 13744 KB Output is correct
50 Correct 71 ms 16432 KB Output is correct
51 Correct 162 ms 27640 KB Output is correct
52 Correct 126 ms 25512 KB Output is correct
53 Correct 151 ms 27640 KB Output is correct
54 Correct 141 ms 31332 KB Output is correct
55 Correct 120 ms 22084 KB Output is correct
56 Correct 131 ms 23052 KB Output is correct
57 Correct 25 ms 10412 KB Output is correct
58 Correct 129 ms 25364 KB Output is correct
59 Correct 131 ms 24840 KB Output is correct
60 Correct 136 ms 30644 KB Output is correct
61 Correct 149 ms 26672 KB Output is correct
62 Correct 25 ms 10404 KB Output is correct
63 Correct 139 ms 22916 KB Output is correct