Submission #698448

# Submission time Handle Problem Language Result Execution time Memory
698448 2023-02-13T13:43:01 Z vjudge1 Drawing (CEOI22_drawing) C++14
100 / 100
237 ms 31108 KB
// 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) {  // cross of a→b, a→c
  LL x1 = b.x - a.x, y1 = b.y - a.y, x2 = c.x - a.x, y2 = c.y - a.y;
  return x1 * y2 - x2 * y1;
}
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));  // O=ps[0] 变成最左下方的点O
  auto pi = begin(ps);
  nth_element(pi, pi + 1, end(ps));
  sort(pi + 1, end(ps),  // 以O为原点, 所有按照极坐标逆时针排序
       [&](const Point& a, const Point& b) { return cross(ps[0], a, b) >= 0; });
  
  vector<int> Ans(N + 1);
  function<void(int, int)> dfs = [&](int u, int fa) {
    Ans[u] = pi->id, pi++;
    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;
}
// AC 100
# Verdict Execution time Memory Grader output
1 Correct 89 ms 8908 KB Output is correct
2 Correct 123 ms 14292 KB Output is correct
3 Correct 99 ms 12060 KB Output is correct
4 Correct 117 ms 16212 KB Output is correct
5 Correct 102 ms 16612 KB Output is correct
6 Correct 87 ms 8980 KB Output is correct
7 Correct 110 ms 9832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 596 KB Output is correct
2 Correct 4 ms 712 KB Output is correct
3 Correct 4 ms 596 KB Output is correct
4 Correct 3 ms 852 KB Output is correct
5 Correct 3 ms 852 KB Output is correct
6 Correct 3 ms 596 KB Output is correct
7 Correct 3 ms 596 KB Output is correct
8 Correct 4 ms 596 KB Output is correct
9 Correct 3 ms 724 KB Output is correct
10 Correct 3 ms 724 KB Output is correct
11 Correct 3 ms 852 KB Output is correct
12 Correct 3 ms 724 KB Output is correct
13 Correct 3 ms 596 KB Output is correct
14 Correct 3 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 596 KB Output is correct
2 Correct 4 ms 712 KB Output is correct
3 Correct 4 ms 596 KB Output is correct
4 Correct 3 ms 852 KB Output is correct
5 Correct 3 ms 852 KB Output is correct
6 Correct 3 ms 596 KB Output is correct
7 Correct 3 ms 596 KB Output is correct
8 Correct 4 ms 596 KB Output is correct
9 Correct 3 ms 724 KB Output is correct
10 Correct 3 ms 724 KB Output is correct
11 Correct 3 ms 852 KB Output is correct
12 Correct 3 ms 724 KB Output is correct
13 Correct 3 ms 596 KB Output is correct
14 Correct 3 ms 596 KB Output is correct
15 Correct 8 ms 980 KB Output is correct
16 Correct 7 ms 1492 KB Output is correct
17 Correct 8 ms 1252 KB Output is correct
18 Correct 7 ms 1748 KB Output is correct
19 Correct 10 ms 1680 KB Output is correct
20 Correct 7 ms 980 KB Output is correct
21 Correct 10 ms 1260 KB Output is correct
22 Correct 8 ms 1004 KB Output is correct
23 Correct 7 ms 1236 KB Output is correct
24 Correct 7 ms 1256 KB Output is correct
25 Correct 8 ms 1748 KB Output is correct
26 Correct 7 ms 1620 KB Output is correct
27 Correct 7 ms 980 KB Output is correct
28 Correct 7 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 596 KB Output is correct
2 Correct 4 ms 712 KB Output is correct
3 Correct 4 ms 596 KB Output is correct
4 Correct 3 ms 852 KB Output is correct
5 Correct 3 ms 852 KB Output is correct
6 Correct 3 ms 596 KB Output is correct
7 Correct 3 ms 596 KB Output is correct
8 Correct 4 ms 596 KB Output is correct
9 Correct 3 ms 724 KB Output is correct
10 Correct 3 ms 724 KB Output is correct
11 Correct 3 ms 852 KB Output is correct
12 Correct 3 ms 724 KB Output is correct
13 Correct 3 ms 596 KB Output is correct
14 Correct 3 ms 596 KB Output is correct
15 Correct 8 ms 980 KB Output is correct
16 Correct 7 ms 1492 KB Output is correct
17 Correct 8 ms 1252 KB Output is correct
18 Correct 7 ms 1748 KB Output is correct
19 Correct 10 ms 1680 KB Output is correct
20 Correct 7 ms 980 KB Output is correct
21 Correct 10 ms 1260 KB Output is correct
22 Correct 8 ms 1004 KB Output is correct
23 Correct 7 ms 1236 KB Output is correct
24 Correct 7 ms 1256 KB Output is correct
25 Correct 8 ms 1748 KB Output is correct
26 Correct 7 ms 1620 KB Output is correct
27 Correct 7 ms 980 KB Output is correct
28 Correct 7 ms 1236 KB Output is correct
29 Correct 67 ms 6408 KB Output is correct
30 Correct 67 ms 10244 KB Output is correct
31 Correct 62 ms 8840 KB Output is correct
32 Correct 64 ms 11984 KB Output is correct
33 Correct 70 ms 10756 KB Output is correct
34 Correct 57 ms 6392 KB Output is correct
35 Correct 62 ms 7424 KB Output is correct
36 Correct 55 ms 5580 KB Output is correct
37 Correct 71 ms 9036 KB Output is correct
38 Correct 62 ms 9272 KB Output is correct
39 Correct 68 ms 10756 KB Output is correct
40 Correct 62 ms 9548 KB Output is correct
41 Correct 51 ms 5580 KB Output is correct
42 Correct 92 ms 7360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 89 ms 8908 KB Output is correct
2 Correct 123 ms 14292 KB Output is correct
3 Correct 99 ms 12060 KB Output is correct
4 Correct 117 ms 16212 KB Output is correct
5 Correct 102 ms 16612 KB Output is correct
6 Correct 87 ms 8980 KB Output is correct
7 Correct 110 ms 9832 KB Output is correct
8 Correct 3 ms 596 KB Output is correct
9 Correct 4 ms 712 KB Output is correct
10 Correct 4 ms 596 KB Output is correct
11 Correct 3 ms 852 KB Output is correct
12 Correct 3 ms 852 KB Output is correct
13 Correct 3 ms 596 KB Output is correct
14 Correct 3 ms 596 KB Output is correct
15 Correct 4 ms 596 KB Output is correct
16 Correct 3 ms 724 KB Output is correct
17 Correct 3 ms 724 KB Output is correct
18 Correct 3 ms 852 KB Output is correct
19 Correct 3 ms 724 KB Output is correct
20 Correct 3 ms 596 KB Output is correct
21 Correct 3 ms 596 KB Output is correct
22 Correct 8 ms 980 KB Output is correct
23 Correct 7 ms 1492 KB Output is correct
24 Correct 8 ms 1252 KB Output is correct
25 Correct 7 ms 1748 KB Output is correct
26 Correct 10 ms 1680 KB Output is correct
27 Correct 7 ms 980 KB Output is correct
28 Correct 10 ms 1260 KB Output is correct
29 Correct 8 ms 1004 KB Output is correct
30 Correct 7 ms 1236 KB Output is correct
31 Correct 7 ms 1256 KB Output is correct
32 Correct 8 ms 1748 KB Output is correct
33 Correct 7 ms 1620 KB Output is correct
34 Correct 7 ms 980 KB Output is correct
35 Correct 7 ms 1236 KB Output is correct
36 Correct 67 ms 6408 KB Output is correct
37 Correct 67 ms 10244 KB Output is correct
38 Correct 62 ms 8840 KB Output is correct
39 Correct 64 ms 11984 KB Output is correct
40 Correct 70 ms 10756 KB Output is correct
41 Correct 57 ms 6392 KB Output is correct
42 Correct 62 ms 7424 KB Output is correct
43 Correct 55 ms 5580 KB Output is correct
44 Correct 71 ms 9036 KB Output is correct
45 Correct 62 ms 9272 KB Output is correct
46 Correct 68 ms 10756 KB Output is correct
47 Correct 62 ms 9548 KB Output is correct
48 Correct 51 ms 5580 KB Output is correct
49 Correct 92 ms 7360 KB Output is correct
50 Correct 105 ms 9864 KB Output is correct
51 Correct 204 ms 25012 KB Output is correct
52 Correct 194 ms 21332 KB Output is correct
53 Correct 211 ms 25804 KB Output is correct
54 Correct 212 ms 31108 KB Output is correct
55 Correct 199 ms 15684 KB Output is correct
56 Correct 237 ms 17336 KB Output is correct
57 Correct 31 ms 3564 KB Output is correct
58 Correct 206 ms 21252 KB Output is correct
59 Correct 191 ms 20344 KB Output is correct
60 Correct 201 ms 30016 KB Output is correct
61 Correct 203 ms 24436 KB Output is correct
62 Correct 30 ms 3456 KB Output is correct
63 Correct 235 ms 17180 KB Output is correct