이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef long long LL;
const int maxn = 1e6 + 10;
int n;
vector<int> G[maxn];
using Point = pair<int, int>;
pair<Point, int> Ps[maxn];
int Ans[maxn];
LL cross(Point a, Point b, Point c) {
  return (LL)a.X * (b.Y - c.Y) + (LL)b.X * (c.Y - a.Y) + (LL)c.X * (a.Y - b.Y);
}
bool cmp(const pair<Point, int>& a, const pair<Point, int>& b) {
  return cross(Ps[0].X, a.X, b.X) >= 0;
}
void solve(int u, int fa, int& pi) {
  Ans[u] = Ps[pi++].second;
  for (int v : G[u])
    if (v != fa) solve(v, u, pi);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n;
  for (int i = 1, a, b; i < n; i++)
    cin >> a >> b, G[a].push_back(b), G[b].push_back(a);
  for (int i = 0, x, y; i < n; i++) cin >> x >> y, Ps[i] = {{x, y}, i + 1};
  sort(Ps, Ps + n);
  sort(Ps + 1, Ps + n, cmp);
  int pi = 0;
  solve(1, 0, pi);
  for (int i = 1; i <= n; i++) printf("%d ", Ans[i]);
  printf("\n");
  return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |