# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
973000 |
2024-05-01T12:02:18 Z |
berr |
Drawing (CEOI22_drawing) |
C++17 |
|
174 ms |
31544 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n; cin >> n;
vector<vector<int>> g(n);
for(int i=1; i<n; i++){
int x, y; cin >> x >> y;
x--; y--;
g[x].push_back(y);
g[y].push_back(x);
}
int r=0, r2=0;
vector<array<int, 2>> e(n);
for(auto &[i, l]: e){
cin >> i >> l;
}
for(int i=0; i<n; i++){
if(g[i].size()==3) r2 = i;
if(e[i][1] < e[r][1]) r=i;
else if(e[i][1]==e[r][1] && e[i][0] > e[r][0]) r=i;
}
vector<int> id(n-1);
int pos=0;
for(int i=0; i<n-1; i++){
if(r==pos) pos++;
id[i]=pos; pos++;
}
auto x=[&](int a, int b){
return e[a][0]-e[b][0];
};
auto y=[&](int a, int b){
return e[a][1]-e[b][1];
};
auto check=[&](int r, int a, int b){
return y(b, r)*x(a, r) < y(a, r)*x(b, r);
};
sort(id.begin(), id.end(), [&](int x, int y){
return check(r, x, y);
});
vector<int> vis(n, -1);
id.push_back(r);
auto dfs=[&](int v, int p, auto&&dfs)->void{
vis[id.back()] = v; id.pop_back();
for(auto i: g[v]){
if(i==p) continue;
dfs(i, v, dfs);
}
};
dfs(r2, r2, dfs);
for(int i=0; i<n; i++) cout<<vis[i]+1<<" ";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
79 ms |
12040 KB |
Output is correct |
2 |
Correct |
71 ms |
16852 KB |
Output is correct |
3 |
Correct |
73 ms |
16860 KB |
Output is correct |
4 |
Correct |
89 ms |
18068 KB |
Output is correct |
5 |
Correct |
72 ms |
15480 KB |
Output is correct |
6 |
Correct |
71 ms |
15708 KB |
Output is correct |
7 |
Correct |
67 ms |
14808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
860 KB |
Output is correct |
2 |
Correct |
2 ms |
1000 KB |
Output is correct |
3 |
Correct |
3 ms |
856 KB |
Output is correct |
4 |
Correct |
3 ms |
860 KB |
Output is correct |
5 |
Correct |
2 ms |
860 KB |
Output is correct |
6 |
Correct |
3 ms |
1008 KB |
Output is correct |
7 |
Correct |
3 ms |
856 KB |
Output is correct |
8 |
Correct |
2 ms |
1000 KB |
Output is correct |
9 |
Correct |
3 ms |
976 KB |
Output is correct |
10 |
Correct |
3 ms |
856 KB |
Output is correct |
11 |
Correct |
3 ms |
856 KB |
Output is correct |
12 |
Correct |
3 ms |
860 KB |
Output is correct |
13 |
Correct |
3 ms |
860 KB |
Output is correct |
14 |
Correct |
2 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
860 KB |
Output is correct |
2 |
Correct |
2 ms |
1000 KB |
Output is correct |
3 |
Correct |
3 ms |
856 KB |
Output is correct |
4 |
Correct |
3 ms |
860 KB |
Output is correct |
5 |
Correct |
2 ms |
860 KB |
Output is correct |
6 |
Correct |
3 ms |
1008 KB |
Output is correct |
7 |
Correct |
3 ms |
856 KB |
Output is correct |
8 |
Correct |
2 ms |
1000 KB |
Output is correct |
9 |
Correct |
3 ms |
976 KB |
Output is correct |
10 |
Correct |
3 ms |
856 KB |
Output is correct |
11 |
Correct |
3 ms |
856 KB |
Output is correct |
12 |
Correct |
3 ms |
860 KB |
Output is correct |
13 |
Correct |
3 ms |
860 KB |
Output is correct |
14 |
Correct |
2 ms |
860 KB |
Output is correct |
15 |
Correct |
8 ms |
1624 KB |
Output is correct |
16 |
Correct |
6 ms |
1884 KB |
Output is correct |
17 |
Correct |
6 ms |
1880 KB |
Output is correct |
18 |
Correct |
6 ms |
1884 KB |
Output is correct |
19 |
Correct |
6 ms |
1744 KB |
Output is correct |
20 |
Correct |
6 ms |
1884 KB |
Output is correct |
21 |
Correct |
6 ms |
1684 KB |
Output is correct |
22 |
Correct |
6 ms |
1628 KB |
Output is correct |
23 |
Correct |
6 ms |
1880 KB |
Output is correct |
24 |
Correct |
8 ms |
1916 KB |
Output is correct |
25 |
Correct |
6 ms |
1884 KB |
Output is correct |
26 |
Correct |
6 ms |
1880 KB |
Output is correct |
27 |
Correct |
6 ms |
1628 KB |
Output is correct |
28 |
Correct |
6 ms |
1680 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
860 KB |
Output is correct |
2 |
Correct |
2 ms |
1000 KB |
Output is correct |
3 |
Correct |
3 ms |
856 KB |
Output is correct |
4 |
Correct |
3 ms |
860 KB |
Output is correct |
5 |
Correct |
2 ms |
860 KB |
Output is correct |
6 |
Correct |
3 ms |
1008 KB |
Output is correct |
7 |
Correct |
3 ms |
856 KB |
Output is correct |
8 |
Correct |
2 ms |
1000 KB |
Output is correct |
9 |
Correct |
3 ms |
976 KB |
Output is correct |
10 |
Correct |
3 ms |
856 KB |
Output is correct |
11 |
Correct |
3 ms |
856 KB |
Output is correct |
12 |
Correct |
3 ms |
860 KB |
Output is correct |
13 |
Correct |
3 ms |
860 KB |
Output is correct |
14 |
Correct |
2 ms |
860 KB |
Output is correct |
15 |
Correct |
8 ms |
1624 KB |
Output is correct |
16 |
Correct |
6 ms |
1884 KB |
Output is correct |
17 |
Correct |
6 ms |
1880 KB |
Output is correct |
18 |
Correct |
6 ms |
1884 KB |
Output is correct |
19 |
Correct |
6 ms |
1744 KB |
Output is correct |
20 |
Correct |
6 ms |
1884 KB |
Output is correct |
21 |
Correct |
6 ms |
1684 KB |
Output is correct |
22 |
Correct |
6 ms |
1628 KB |
Output is correct |
23 |
Correct |
6 ms |
1880 KB |
Output is correct |
24 |
Correct |
8 ms |
1916 KB |
Output is correct |
25 |
Correct |
6 ms |
1884 KB |
Output is correct |
26 |
Correct |
6 ms |
1880 KB |
Output is correct |
27 |
Correct |
6 ms |
1628 KB |
Output is correct |
28 |
Correct |
6 ms |
1680 KB |
Output is correct |
29 |
Correct |
49 ms |
11088 KB |
Output is correct |
30 |
Correct |
50 ms |
11392 KB |
Output is correct |
31 |
Correct |
50 ms |
11996 KB |
Output is correct |
32 |
Correct |
47 ms |
11844 KB |
Output is correct |
33 |
Correct |
48 ms |
11744 KB |
Output is correct |
34 |
Correct |
56 ms |
11344 KB |
Output is correct |
35 |
Correct |
52 ms |
10464 KB |
Output is correct |
36 |
Correct |
40 ms |
9584 KB |
Output is correct |
37 |
Correct |
49 ms |
11744 KB |
Output is correct |
38 |
Correct |
49 ms |
11744 KB |
Output is correct |
39 |
Correct |
58 ms |
11748 KB |
Output is correct |
40 |
Correct |
47 ms |
11740 KB |
Output is correct |
41 |
Correct |
47 ms |
9868 KB |
Output is correct |
42 |
Correct |
47 ms |
10460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
79 ms |
12040 KB |
Output is correct |
2 |
Correct |
71 ms |
16852 KB |
Output is correct |
3 |
Correct |
73 ms |
16860 KB |
Output is correct |
4 |
Correct |
89 ms |
18068 KB |
Output is correct |
5 |
Correct |
72 ms |
15480 KB |
Output is correct |
6 |
Correct |
71 ms |
15708 KB |
Output is correct |
7 |
Correct |
67 ms |
14808 KB |
Output is correct |
8 |
Correct |
3 ms |
860 KB |
Output is correct |
9 |
Correct |
2 ms |
1000 KB |
Output is correct |
10 |
Correct |
3 ms |
856 KB |
Output is correct |
11 |
Correct |
3 ms |
860 KB |
Output is correct |
12 |
Correct |
2 ms |
860 KB |
Output is correct |
13 |
Correct |
3 ms |
1008 KB |
Output is correct |
14 |
Correct |
3 ms |
856 KB |
Output is correct |
15 |
Correct |
2 ms |
1000 KB |
Output is correct |
16 |
Correct |
3 ms |
976 KB |
Output is correct |
17 |
Correct |
3 ms |
856 KB |
Output is correct |
18 |
Correct |
3 ms |
856 KB |
Output is correct |
19 |
Correct |
3 ms |
860 KB |
Output is correct |
20 |
Correct |
3 ms |
860 KB |
Output is correct |
21 |
Correct |
2 ms |
860 KB |
Output is correct |
22 |
Correct |
8 ms |
1624 KB |
Output is correct |
23 |
Correct |
6 ms |
1884 KB |
Output is correct |
24 |
Correct |
6 ms |
1880 KB |
Output is correct |
25 |
Correct |
6 ms |
1884 KB |
Output is correct |
26 |
Correct |
6 ms |
1744 KB |
Output is correct |
27 |
Correct |
6 ms |
1884 KB |
Output is correct |
28 |
Correct |
6 ms |
1684 KB |
Output is correct |
29 |
Correct |
6 ms |
1628 KB |
Output is correct |
30 |
Correct |
6 ms |
1880 KB |
Output is correct |
31 |
Correct |
8 ms |
1916 KB |
Output is correct |
32 |
Correct |
6 ms |
1884 KB |
Output is correct |
33 |
Correct |
6 ms |
1880 KB |
Output is correct |
34 |
Correct |
6 ms |
1628 KB |
Output is correct |
35 |
Correct |
6 ms |
1680 KB |
Output is correct |
36 |
Correct |
49 ms |
11088 KB |
Output is correct |
37 |
Correct |
50 ms |
11392 KB |
Output is correct |
38 |
Correct |
50 ms |
11996 KB |
Output is correct |
39 |
Correct |
47 ms |
11844 KB |
Output is correct |
40 |
Correct |
48 ms |
11744 KB |
Output is correct |
41 |
Correct |
56 ms |
11344 KB |
Output is correct |
42 |
Correct |
52 ms |
10464 KB |
Output is correct |
43 |
Correct |
40 ms |
9584 KB |
Output is correct |
44 |
Correct |
49 ms |
11744 KB |
Output is correct |
45 |
Correct |
49 ms |
11744 KB |
Output is correct |
46 |
Correct |
58 ms |
11748 KB |
Output is correct |
47 |
Correct |
47 ms |
11740 KB |
Output is correct |
48 |
Correct |
47 ms |
9868 KB |
Output is correct |
49 |
Correct |
47 ms |
10460 KB |
Output is correct |
50 |
Correct |
82 ms |
17232 KB |
Output is correct |
51 |
Correct |
174 ms |
28220 KB |
Output is correct |
52 |
Correct |
147 ms |
30976 KB |
Output is correct |
53 |
Correct |
150 ms |
28328 KB |
Output is correct |
54 |
Correct |
164 ms |
30724 KB |
Output is correct |
55 |
Correct |
137 ms |
29008 KB |
Output is correct |
56 |
Correct |
165 ms |
26156 KB |
Output is correct |
57 |
Correct |
25 ms |
5976 KB |
Output is correct |
58 |
Correct |
170 ms |
30172 KB |
Output is correct |
59 |
Correct |
150 ms |
30084 KB |
Output is correct |
60 |
Correct |
144 ms |
31544 KB |
Output is correct |
61 |
Correct |
157 ms |
28964 KB |
Output is correct |
62 |
Correct |
25 ms |
6236 KB |
Output is correct |
63 |
Correct |
162 ms |
25908 KB |
Output is correct |