Submission #698409

# Submission time Handle Problem Language Result Execution time Memory
698409 2023-02-13T11:37:52 Z vjudge1 Drawing (CEOI22_drawing) C++14
100 / 100
260 ms 39628 KB
#include <bits/stdc++.h>
#define X first
#define Y second

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;
  }
};

const int maxn = 1e6 + 10;
int n;
vector<int> G[maxn];
// using Point = pair<int, int>;
// pair<Point, int> Ps[maxn];
Point 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 Point& a, const Point& b) { return cross(Ps[0], a, b) >= 0; }
void solve(int u, int fa, int& pi) {
  Ans[u] = Ps[pi++].id;
  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
1 Correct 108 ms 30156 KB Output is correct
2 Correct 129 ms 31804 KB Output is correct
3 Correct 111 ms 31112 KB Output is correct
4 Correct 150 ms 32748 KB Output is correct
5 Correct 123 ms 32396 KB Output is correct
6 Correct 113 ms 30096 KB Output is correct
7 Correct 123 ms 30416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 24012 KB Output is correct
2 Correct 16 ms 24080 KB Output is correct
3 Correct 15 ms 24100 KB Output is correct
4 Correct 15 ms 24208 KB Output is correct
5 Correct 16 ms 24144 KB Output is correct
6 Correct 16 ms 24140 KB Output is correct
7 Correct 19 ms 24148 KB Output is correct
8 Correct 16 ms 24020 KB Output is correct
9 Correct 19 ms 24276 KB Output is correct
10 Correct 17 ms 24136 KB Output is correct
11 Correct 16 ms 24208 KB Output is correct
12 Correct 16 ms 24136 KB Output is correct
13 Correct 16 ms 24020 KB Output is correct
14 Correct 15 ms 24148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 24012 KB Output is correct
2 Correct 16 ms 24080 KB Output is correct
3 Correct 15 ms 24100 KB Output is correct
4 Correct 15 ms 24208 KB Output is correct
5 Correct 16 ms 24144 KB Output is correct
6 Correct 16 ms 24140 KB Output is correct
7 Correct 19 ms 24148 KB Output is correct
8 Correct 16 ms 24020 KB Output is correct
9 Correct 19 ms 24276 KB Output is correct
10 Correct 17 ms 24136 KB Output is correct
11 Correct 16 ms 24208 KB Output is correct
12 Correct 16 ms 24136 KB Output is correct
13 Correct 16 ms 24020 KB Output is correct
14 Correct 15 ms 24148 KB Output is correct
15 Correct 20 ms 24532 KB Output is correct
16 Correct 20 ms 24532 KB Output is correct
17 Correct 21 ms 24404 KB Output is correct
18 Correct 25 ms 24644 KB Output is correct
19 Correct 21 ms 24592 KB Output is correct
20 Correct 21 ms 24464 KB Output is correct
21 Correct 21 ms 24532 KB Output is correct
22 Correct 21 ms 24400 KB Output is correct
23 Correct 24 ms 24532 KB Output is correct
24 Correct 20 ms 24540 KB Output is correct
25 Correct 22 ms 24672 KB Output is correct
26 Correct 20 ms 24588 KB Output is correct
27 Correct 20 ms 24392 KB Output is correct
28 Correct 19 ms 24540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 24012 KB Output is correct
2 Correct 16 ms 24080 KB Output is correct
3 Correct 15 ms 24100 KB Output is correct
4 Correct 15 ms 24208 KB Output is correct
5 Correct 16 ms 24144 KB Output is correct
6 Correct 16 ms 24140 KB Output is correct
7 Correct 19 ms 24148 KB Output is correct
8 Correct 16 ms 24020 KB Output is correct
9 Correct 19 ms 24276 KB Output is correct
10 Correct 17 ms 24136 KB Output is correct
11 Correct 16 ms 24208 KB Output is correct
12 Correct 16 ms 24136 KB Output is correct
13 Correct 16 ms 24020 KB Output is correct
14 Correct 15 ms 24148 KB Output is correct
15 Correct 20 ms 24532 KB Output is correct
16 Correct 20 ms 24532 KB Output is correct
17 Correct 21 ms 24404 KB Output is correct
18 Correct 25 ms 24644 KB Output is correct
19 Correct 21 ms 24592 KB Output is correct
20 Correct 21 ms 24464 KB Output is correct
21 Correct 21 ms 24532 KB Output is correct
22 Correct 21 ms 24400 KB Output is correct
23 Correct 24 ms 24532 KB Output is correct
24 Correct 20 ms 24540 KB Output is correct
25 Correct 22 ms 24672 KB Output is correct
26 Correct 20 ms 24588 KB Output is correct
27 Correct 20 ms 24392 KB Output is correct
28 Correct 19 ms 24540 KB Output is correct
29 Correct 82 ms 28276 KB Output is correct
30 Correct 86 ms 29448 KB Output is correct
31 Correct 88 ms 29064 KB Output is correct
32 Correct 97 ms 29972 KB Output is correct
33 Correct 84 ms 29612 KB Output is correct
34 Correct 78 ms 28324 KB Output is correct
35 Correct 77 ms 28580 KB Output is correct
36 Correct 76 ms 27716 KB Output is correct
37 Correct 90 ms 29160 KB Output is correct
38 Correct 81 ms 29188 KB Output is correct
39 Correct 103 ms 29612 KB Output is correct
40 Correct 79 ms 29260 KB Output is correct
41 Correct 66 ms 27724 KB Output is correct
42 Correct 90 ms 28748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 108 ms 30156 KB Output is correct
2 Correct 129 ms 31804 KB Output is correct
3 Correct 111 ms 31112 KB Output is correct
4 Correct 150 ms 32748 KB Output is correct
5 Correct 123 ms 32396 KB Output is correct
6 Correct 113 ms 30096 KB Output is correct
7 Correct 123 ms 30416 KB Output is correct
8 Correct 18 ms 24012 KB Output is correct
9 Correct 16 ms 24080 KB Output is correct
10 Correct 15 ms 24100 KB Output is correct
11 Correct 15 ms 24208 KB Output is correct
12 Correct 16 ms 24144 KB Output is correct
13 Correct 16 ms 24140 KB Output is correct
14 Correct 19 ms 24148 KB Output is correct
15 Correct 16 ms 24020 KB Output is correct
16 Correct 19 ms 24276 KB Output is correct
17 Correct 17 ms 24136 KB Output is correct
18 Correct 16 ms 24208 KB Output is correct
19 Correct 16 ms 24136 KB Output is correct
20 Correct 16 ms 24020 KB Output is correct
21 Correct 15 ms 24148 KB Output is correct
22 Correct 20 ms 24532 KB Output is correct
23 Correct 20 ms 24532 KB Output is correct
24 Correct 21 ms 24404 KB Output is correct
25 Correct 25 ms 24644 KB Output is correct
26 Correct 21 ms 24592 KB Output is correct
27 Correct 21 ms 24464 KB Output is correct
28 Correct 21 ms 24532 KB Output is correct
29 Correct 21 ms 24400 KB Output is correct
30 Correct 24 ms 24532 KB Output is correct
31 Correct 20 ms 24540 KB Output is correct
32 Correct 22 ms 24672 KB Output is correct
33 Correct 20 ms 24588 KB Output is correct
34 Correct 20 ms 24392 KB Output is correct
35 Correct 19 ms 24540 KB Output is correct
36 Correct 82 ms 28276 KB Output is correct
37 Correct 86 ms 29448 KB Output is correct
38 Correct 88 ms 29064 KB Output is correct
39 Correct 97 ms 29972 KB Output is correct
40 Correct 84 ms 29612 KB Output is correct
41 Correct 78 ms 28324 KB Output is correct
42 Correct 77 ms 28580 KB Output is correct
43 Correct 76 ms 27716 KB Output is correct
44 Correct 90 ms 29160 KB Output is correct
45 Correct 81 ms 29188 KB Output is correct
46 Correct 103 ms 29612 KB Output is correct
47 Correct 79 ms 29260 KB Output is correct
48 Correct 66 ms 27724 KB Output is correct
49 Correct 90 ms 28748 KB Output is correct
50 Correct 132 ms 30816 KB Output is correct
51 Correct 248 ms 37868 KB Output is correct
52 Correct 236 ms 36592 KB Output is correct
53 Correct 242 ms 37984 KB Output is correct
54 Correct 245 ms 39628 KB Output is correct
55 Correct 218 ms 34720 KB Output is correct
56 Correct 222 ms 35172 KB Output is correct
57 Correct 48 ms 26044 KB Output is correct
58 Correct 232 ms 36368 KB Output is correct
59 Correct 259 ms 36100 KB Output is correct
60 Correct 260 ms 39120 KB Output is correct
61 Correct 214 ms 37452 KB Output is correct
62 Correct 48 ms 26148 KB Output is correct
63 Correct 231 ms 35244 KB Output is correct