Submission #698444

# Submission time Handle Problem Language Result Execution time Memory
698444 2023-02-13T13:29:11 Z vjudge1 Drawing (CEOI22_drawing) C++14
100 / 100
244 ms 33384 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) {
  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));
  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;
}
// AC 100
# Verdict Execution time Memory Grader output
1 Correct 114 ms 11212 KB Output is correct
2 Correct 99 ms 16640 KB Output is correct
3 Correct 112 ms 14228 KB Output is correct
4 Correct 115 ms 18568 KB Output is correct
5 Correct 102 ms 18764 KB Output is correct
6 Correct 99 ms 11164 KB Output is correct
7 Correct 98 ms 12112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 724 KB Output is correct
2 Correct 3 ms 852 KB Output is correct
3 Correct 4 ms 708 KB Output is correct
4 Correct 4 ms 980 KB Output is correct
5 Correct 4 ms 948 KB Output is correct
6 Correct 4 ms 692 KB Output is correct
7 Correct 4 ms 704 KB Output is correct
8 Correct 3 ms 724 KB Output is correct
9 Correct 4 ms 824 KB Output is correct
10 Correct 3 ms 832 KB Output is correct
11 Correct 3 ms 980 KB Output is correct
12 Correct 3 ms 852 KB Output is correct
13 Correct 3 ms 704 KB Output is correct
14 Correct 3 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 724 KB Output is correct
2 Correct 3 ms 852 KB Output is correct
3 Correct 4 ms 708 KB Output is correct
4 Correct 4 ms 980 KB Output is correct
5 Correct 4 ms 948 KB Output is correct
6 Correct 4 ms 692 KB Output is correct
7 Correct 4 ms 704 KB Output is correct
8 Correct 3 ms 724 KB Output is correct
9 Correct 4 ms 824 KB Output is correct
10 Correct 3 ms 832 KB Output is correct
11 Correct 3 ms 980 KB Output is correct
12 Correct 3 ms 852 KB Output is correct
13 Correct 3 ms 704 KB Output is correct
14 Correct 3 ms 724 KB Output is correct
15 Correct 8 ms 1368 KB Output is correct
16 Correct 10 ms 1748 KB Output is correct
17 Correct 7 ms 1480 KB Output is correct
18 Correct 7 ms 1996 KB Output is correct
19 Correct 8 ms 2020 KB Output is correct
20 Correct 7 ms 1372 KB Output is correct
21 Correct 7 ms 1496 KB Output is correct
22 Correct 8 ms 1292 KB Output is correct
23 Correct 7 ms 1608 KB Output is correct
24 Correct 7 ms 1492 KB Output is correct
25 Correct 9 ms 2004 KB Output is correct
26 Correct 7 ms 1876 KB Output is correct
27 Correct 7 ms 1356 KB Output is correct
28 Correct 8 ms 1492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 724 KB Output is correct
2 Correct 3 ms 852 KB Output is correct
3 Correct 4 ms 708 KB Output is correct
4 Correct 4 ms 980 KB Output is correct
5 Correct 4 ms 948 KB Output is correct
6 Correct 4 ms 692 KB Output is correct
7 Correct 4 ms 704 KB Output is correct
8 Correct 3 ms 724 KB Output is correct
9 Correct 4 ms 824 KB Output is correct
10 Correct 3 ms 832 KB Output is correct
11 Correct 3 ms 980 KB Output is correct
12 Correct 3 ms 852 KB Output is correct
13 Correct 3 ms 704 KB Output is correct
14 Correct 3 ms 724 KB Output is correct
15 Correct 8 ms 1368 KB Output is correct
16 Correct 10 ms 1748 KB Output is correct
17 Correct 7 ms 1480 KB Output is correct
18 Correct 7 ms 1996 KB Output is correct
19 Correct 8 ms 2020 KB Output is correct
20 Correct 7 ms 1372 KB Output is correct
21 Correct 7 ms 1496 KB Output is correct
22 Correct 8 ms 1292 KB Output is correct
23 Correct 7 ms 1608 KB Output is correct
24 Correct 7 ms 1492 KB Output is correct
25 Correct 9 ms 2004 KB Output is correct
26 Correct 7 ms 1876 KB Output is correct
27 Correct 7 ms 1356 KB Output is correct
28 Correct 8 ms 1492 KB Output is correct
29 Correct 61 ms 8520 KB Output is correct
30 Correct 91 ms 12412 KB Output is correct
31 Correct 69 ms 11068 KB Output is correct
32 Correct 69 ms 14136 KB Output is correct
33 Correct 73 ms 12944 KB Output is correct
34 Correct 70 ms 8524 KB Output is correct
35 Correct 67 ms 9492 KB Output is correct
36 Correct 52 ms 7584 KB Output is correct
37 Correct 86 ms 11196 KB Output is correct
38 Correct 66 ms 11424 KB Output is correct
39 Correct 77 ms 12868 KB Output is correct
40 Correct 65 ms 11720 KB Output is correct
41 Correct 58 ms 7736 KB Output is correct
42 Correct 73 ms 9600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 114 ms 11212 KB Output is correct
2 Correct 99 ms 16640 KB Output is correct
3 Correct 112 ms 14228 KB Output is correct
4 Correct 115 ms 18568 KB Output is correct
5 Correct 102 ms 18764 KB Output is correct
6 Correct 99 ms 11164 KB Output is correct
7 Correct 98 ms 12112 KB Output is correct
8 Correct 3 ms 724 KB Output is correct
9 Correct 3 ms 852 KB Output is correct
10 Correct 4 ms 708 KB Output is correct
11 Correct 4 ms 980 KB Output is correct
12 Correct 4 ms 948 KB Output is correct
13 Correct 4 ms 692 KB Output is correct
14 Correct 4 ms 704 KB Output is correct
15 Correct 3 ms 724 KB Output is correct
16 Correct 4 ms 824 KB Output is correct
17 Correct 3 ms 832 KB Output is correct
18 Correct 3 ms 980 KB Output is correct
19 Correct 3 ms 852 KB Output is correct
20 Correct 3 ms 704 KB Output is correct
21 Correct 3 ms 724 KB Output is correct
22 Correct 8 ms 1368 KB Output is correct
23 Correct 10 ms 1748 KB Output is correct
24 Correct 7 ms 1480 KB Output is correct
25 Correct 7 ms 1996 KB Output is correct
26 Correct 8 ms 2020 KB Output is correct
27 Correct 7 ms 1372 KB Output is correct
28 Correct 7 ms 1496 KB Output is correct
29 Correct 8 ms 1292 KB Output is correct
30 Correct 7 ms 1608 KB Output is correct
31 Correct 7 ms 1492 KB Output is correct
32 Correct 9 ms 2004 KB Output is correct
33 Correct 7 ms 1876 KB Output is correct
34 Correct 7 ms 1356 KB Output is correct
35 Correct 8 ms 1492 KB Output is correct
36 Correct 61 ms 8520 KB Output is correct
37 Correct 91 ms 12412 KB Output is correct
38 Correct 69 ms 11068 KB Output is correct
39 Correct 69 ms 14136 KB Output is correct
40 Correct 73 ms 12944 KB Output is correct
41 Correct 70 ms 8524 KB Output is correct
42 Correct 67 ms 9492 KB Output is correct
43 Correct 52 ms 7584 KB Output is correct
44 Correct 86 ms 11196 KB Output is correct
45 Correct 66 ms 11424 KB Output is correct
46 Correct 77 ms 12868 KB Output is correct
47 Correct 65 ms 11720 KB Output is correct
48 Correct 58 ms 7736 KB Output is correct
49 Correct 73 ms 9600 KB Output is correct
50 Correct 110 ms 12188 KB Output is correct
51 Correct 224 ms 27364 KB Output is correct
52 Correct 232 ms 23612 KB Output is correct
53 Correct 219 ms 28092 KB Output is correct
54 Correct 234 ms 33384 KB Output is correct
55 Correct 229 ms 17988 KB Output is correct
56 Correct 230 ms 19676 KB Output is correct
57 Correct 34 ms 4856 KB Output is correct
58 Correct 217 ms 23536 KB Output is correct
59 Correct 244 ms 22704 KB Output is correct
60 Correct 215 ms 32312 KB Output is correct
61 Correct 213 ms 26788 KB Output is correct
62 Correct 41 ms 4884 KB Output is correct
63 Correct 218 ms 19580 KB Output is correct