Submission #698430

# Submission time Handle Problem Language Result Execution time Memory
698430 2023-02-13T12:56:04 Z vjudge1 Drawing (CEOI22_drawing) C++14
100 / 100
243 ms 31012 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) {
  return (LL)a.x * (b.y - c.y) + (LL)b.x * (c.y - a.y) + (LL)c.x * (a.y - b.y);
}
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));
  sort(begin(ps) + 1, end(ps),
       [&](const Point& a, const Point& b) { return cross(ps[0], a, b) >= 0; });

  vector<int> Ans(N + 1);
  auto pi = begin(ps);
  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;
}
# Verdict Execution time Memory Grader output
1 Correct 116 ms 9004 KB Output is correct
2 Correct 98 ms 14300 KB Output is correct
3 Correct 97 ms 11980 KB Output is correct
4 Correct 135 ms 16276 KB Output is correct
5 Correct 95 ms 16680 KB Output is correct
6 Correct 89 ms 8900 KB Output is correct
7 Correct 108 ms 9828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 596 KB Output is correct
2 Correct 3 ms 724 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 4 ms 596 KB Output is correct
8 Correct 4 ms 596 KB Output is correct
9 Correct 4 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 588 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 3 ms 724 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 4 ms 596 KB Output is correct
8 Correct 4 ms 596 KB Output is correct
9 Correct 4 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 588 KB Output is correct
14 Correct 3 ms 596 KB Output is correct
15 Correct 7 ms 980 KB Output is correct
16 Correct 7 ms 1492 KB Output is correct
17 Correct 8 ms 1236 KB Output is correct
18 Correct 9 ms 1748 KB Output is correct
19 Correct 8 ms 1704 KB Output is correct
20 Correct 7 ms 980 KB Output is correct
21 Correct 8 ms 1260 KB Output is correct
22 Correct 7 ms 980 KB Output is correct
23 Correct 7 ms 1236 KB Output is correct
24 Correct 9 ms 1248 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 13 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 596 KB Output is correct
2 Correct 3 ms 724 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 4 ms 596 KB Output is correct
8 Correct 4 ms 596 KB Output is correct
9 Correct 4 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 588 KB Output is correct
14 Correct 3 ms 596 KB Output is correct
15 Correct 7 ms 980 KB Output is correct
16 Correct 7 ms 1492 KB Output is correct
17 Correct 8 ms 1236 KB Output is correct
18 Correct 9 ms 1748 KB Output is correct
19 Correct 8 ms 1704 KB Output is correct
20 Correct 7 ms 980 KB Output is correct
21 Correct 8 ms 1260 KB Output is correct
22 Correct 7 ms 980 KB Output is correct
23 Correct 7 ms 1236 KB Output is correct
24 Correct 9 ms 1248 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 13 ms 1236 KB Output is correct
29 Correct 76 ms 6292 KB Output is correct
30 Correct 65 ms 10228 KB Output is correct
31 Correct 76 ms 8848 KB Output is correct
32 Correct 72 ms 12008 KB Output is correct
33 Correct 68 ms 10700 KB Output is correct
34 Correct 61 ms 6424 KB Output is correct
35 Correct 64 ms 7312 KB Output is correct
36 Correct 59 ms 5452 KB Output is correct
37 Correct 66 ms 9112 KB Output is correct
38 Correct 68 ms 9420 KB Output is correct
39 Correct 73 ms 10752 KB Output is correct
40 Correct 72 ms 9548 KB Output is correct
41 Correct 52 ms 5496 KB Output is correct
42 Correct 63 ms 7372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 116 ms 9004 KB Output is correct
2 Correct 98 ms 14300 KB Output is correct
3 Correct 97 ms 11980 KB Output is correct
4 Correct 135 ms 16276 KB Output is correct
5 Correct 95 ms 16680 KB Output is correct
6 Correct 89 ms 8900 KB Output is correct
7 Correct 108 ms 9828 KB Output is correct
8 Correct 3 ms 596 KB Output is correct
9 Correct 3 ms 724 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 4 ms 596 KB Output is correct
15 Correct 4 ms 596 KB Output is correct
16 Correct 4 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 588 KB Output is correct
21 Correct 3 ms 596 KB Output is correct
22 Correct 7 ms 980 KB Output is correct
23 Correct 7 ms 1492 KB Output is correct
24 Correct 8 ms 1236 KB Output is correct
25 Correct 9 ms 1748 KB Output is correct
26 Correct 8 ms 1704 KB Output is correct
27 Correct 7 ms 980 KB Output is correct
28 Correct 8 ms 1260 KB Output is correct
29 Correct 7 ms 980 KB Output is correct
30 Correct 7 ms 1236 KB Output is correct
31 Correct 9 ms 1248 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 13 ms 1236 KB Output is correct
36 Correct 76 ms 6292 KB Output is correct
37 Correct 65 ms 10228 KB Output is correct
38 Correct 76 ms 8848 KB Output is correct
39 Correct 72 ms 12008 KB Output is correct
40 Correct 68 ms 10700 KB Output is correct
41 Correct 61 ms 6424 KB Output is correct
42 Correct 64 ms 7312 KB Output is correct
43 Correct 59 ms 5452 KB Output is correct
44 Correct 66 ms 9112 KB Output is correct
45 Correct 68 ms 9420 KB Output is correct
46 Correct 73 ms 10752 KB Output is correct
47 Correct 72 ms 9548 KB Output is correct
48 Correct 52 ms 5496 KB Output is correct
49 Correct 63 ms 7372 KB Output is correct
50 Correct 117 ms 9844 KB Output is correct
51 Correct 204 ms 24948 KB Output is correct
52 Correct 225 ms 21324 KB Output is correct
53 Correct 243 ms 25908 KB Output is correct
54 Correct 221 ms 31012 KB Output is correct
55 Correct 216 ms 15732 KB Output is correct
56 Correct 204 ms 17360 KB Output is correct
57 Correct 40 ms 3532 KB Output is correct
58 Correct 208 ms 21224 KB Output is correct
59 Correct 195 ms 20416 KB Output is correct
60 Correct 236 ms 29956 KB Output is correct
61 Correct 233 ms 24508 KB Output is correct
62 Correct 32 ms 3556 KB Output is correct
63 Correct 197 ms 17116 KB Output is correct