#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int, int>
#define vpii vector<pair<int, int>>
#define vc vector<char>
#define vb vector<bool>
#define mii map<int,int>
#define f0r(i,n) for(int i=0;i<n;i++)
#define FOR(i,k,n) for(int i=k;i<n;i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define in(a) int a; cin>>a
#define in2(a,b) int a,b; cin>>a>>b
#define in3(a,b,c) int a,b,c; cin>>a>>b>>c
#define in4(a,b,c,d) int a,b,c,d; cin>>a>>b>>c>>d
#define vin(v,n); vi v(n); f0r(i,n){cin>>v[i];}
#define out(a) cout<<a<<'\n'
#define out2(a,b) cout<<a<<' '<<b<<'\n'
#define out3(a,b,c) cout<<a<<' '<<b<<' '<<c<<'\n'
#define out4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d<<'\n'
#define vout(v) cout<<#v<<' '; for(auto u : v){cout<<u<<' ';} cout<<'\n'
#define dout(a) cout<<a<<' '<<#a<<'\n'
#define dout2(a,b) cout<<a<<' '<<#a<<' '<<b<<' '<<#b<<'\n'
#define yn(x); if(x){cout<<"YES"<<'\n';}else{cout<<"NO"<<'\n';}
const int leg = 1e9 + 7;
const int mod = 998244353;
using namespace std;
const int mxn = 2e5 + 5;
vi order;
vi adj[mxn];
void dfs(int x, int from){
order.pb(x);
for(auto u : adj[x]){
if(u != from){
dfs(u,x);
}
}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
//ifstream cin(".in");
//ofstream cout(".out");
in(n);
f0r(i,n-1){
in2(a,b);
adj[a].pb(b);
adj[b].pb(a);
}
vector<pair<double,double>> pts;
f0r(i,n){
in2(a,b);
pts.pb(make_pair(a,b));
}
vector<pair<double,int>> angs;
FOR(i, 1, n){
angs.pb({atan((pts[0].second - pts[i].second)/(pts[0].first - pts[i].first)),i});
}
sort(all(angs));
vi poly;
poly.pb(0);
f0r(i, n-1){
poly.pb(angs[i].second);
}
//vout(poly);
FOR(i, 1, n+1){
//vout(adj[i]);
}
dfs(1, -1);
vi ans(n);
f0r(i,n){
ans[poly[i]] = order[i];
}
for(auto u : ans)cout<<u<<' ';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
85 ms |
20700 KB |
Output is correct |
2 |
Correct |
90 ms |
23608 KB |
Output is correct |
3 |
Correct |
89 ms |
22848 KB |
Output is correct |
4 |
Correct |
97 ms |
24632 KB |
Output is correct |
5 |
Correct |
83 ms |
24124 KB |
Output is correct |
6 |
Correct |
80 ms |
21052 KB |
Output is correct |
7 |
Correct |
93 ms |
20280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
5712 KB |
Output is correct |
2 |
Correct |
6 ms |
5712 KB |
Output is correct |
3 |
Correct |
5 ms |
5712 KB |
Output is correct |
4 |
Correct |
6 ms |
5684 KB |
Output is correct |
5 |
Correct |
6 ms |
5712 KB |
Output is correct |
6 |
Correct |
6 ms |
5712 KB |
Output is correct |
7 |
Correct |
6 ms |
5712 KB |
Output is correct |
8 |
Correct |
6 ms |
5712 KB |
Output is correct |
9 |
Correct |
5 ms |
5712 KB |
Output is correct |
10 |
Correct |
6 ms |
5712 KB |
Output is correct |
11 |
Correct |
5 ms |
5612 KB |
Output is correct |
12 |
Correct |
6 ms |
5712 KB |
Output is correct |
13 |
Correct |
5 ms |
5880 KB |
Output is correct |
14 |
Correct |
6 ms |
5884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
5712 KB |
Output is correct |
2 |
Correct |
6 ms |
5712 KB |
Output is correct |
3 |
Correct |
5 ms |
5712 KB |
Output is correct |
4 |
Correct |
6 ms |
5684 KB |
Output is correct |
5 |
Correct |
6 ms |
5712 KB |
Output is correct |
6 |
Correct |
6 ms |
5712 KB |
Output is correct |
7 |
Correct |
6 ms |
5712 KB |
Output is correct |
8 |
Correct |
6 ms |
5712 KB |
Output is correct |
9 |
Correct |
5 ms |
5712 KB |
Output is correct |
10 |
Correct |
6 ms |
5712 KB |
Output is correct |
11 |
Correct |
5 ms |
5612 KB |
Output is correct |
12 |
Correct |
6 ms |
5712 KB |
Output is correct |
13 |
Correct |
5 ms |
5880 KB |
Output is correct |
14 |
Correct |
6 ms |
5884 KB |
Output is correct |
15 |
Correct |
11 ms |
6476 KB |
Output is correct |
16 |
Correct |
10 ms |
6732 KB |
Output is correct |
17 |
Correct |
9 ms |
6512 KB |
Output is correct |
18 |
Correct |
9 ms |
6676 KB |
Output is correct |
19 |
Correct |
11 ms |
6732 KB |
Output is correct |
20 |
Correct |
10 ms |
6480 KB |
Output is correct |
21 |
Correct |
10 ms |
6480 KB |
Output is correct |
22 |
Correct |
11 ms |
6476 KB |
Output is correct |
23 |
Correct |
10 ms |
6476 KB |
Output is correct |
24 |
Correct |
12 ms |
6476 KB |
Output is correct |
25 |
Correct |
10 ms |
6704 KB |
Output is correct |
26 |
Correct |
10 ms |
6732 KB |
Output is correct |
27 |
Correct |
10 ms |
6480 KB |
Output is correct |
28 |
Correct |
10 ms |
6648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
5712 KB |
Output is correct |
2 |
Correct |
6 ms |
5712 KB |
Output is correct |
3 |
Correct |
5 ms |
5712 KB |
Output is correct |
4 |
Correct |
6 ms |
5684 KB |
Output is correct |
5 |
Correct |
6 ms |
5712 KB |
Output is correct |
6 |
Correct |
6 ms |
5712 KB |
Output is correct |
7 |
Correct |
6 ms |
5712 KB |
Output is correct |
8 |
Correct |
6 ms |
5712 KB |
Output is correct |
9 |
Correct |
5 ms |
5712 KB |
Output is correct |
10 |
Correct |
6 ms |
5712 KB |
Output is correct |
11 |
Correct |
5 ms |
5612 KB |
Output is correct |
12 |
Correct |
6 ms |
5712 KB |
Output is correct |
13 |
Correct |
5 ms |
5880 KB |
Output is correct |
14 |
Correct |
6 ms |
5884 KB |
Output is correct |
15 |
Correct |
11 ms |
6476 KB |
Output is correct |
16 |
Correct |
10 ms |
6732 KB |
Output is correct |
17 |
Correct |
9 ms |
6512 KB |
Output is correct |
18 |
Correct |
9 ms |
6676 KB |
Output is correct |
19 |
Correct |
11 ms |
6732 KB |
Output is correct |
20 |
Correct |
10 ms |
6480 KB |
Output is correct |
21 |
Correct |
10 ms |
6480 KB |
Output is correct |
22 |
Correct |
11 ms |
6476 KB |
Output is correct |
23 |
Correct |
10 ms |
6476 KB |
Output is correct |
24 |
Correct |
12 ms |
6476 KB |
Output is correct |
25 |
Correct |
10 ms |
6704 KB |
Output is correct |
26 |
Correct |
10 ms |
6732 KB |
Output is correct |
27 |
Correct |
10 ms |
6480 KB |
Output is correct |
28 |
Correct |
10 ms |
6648 KB |
Output is correct |
29 |
Correct |
63 ms |
17472 KB |
Output is correct |
30 |
Correct |
80 ms |
19748 KB |
Output is correct |
31 |
Correct |
66 ms |
19232 KB |
Output is correct |
32 |
Correct |
68 ms |
19932 KB |
Output is correct |
33 |
Correct |
75 ms |
19520 KB |
Output is correct |
34 |
Correct |
64 ms |
17708 KB |
Output is correct |
35 |
Correct |
80 ms |
17700 KB |
Output is correct |
36 |
Correct |
54 ms |
16540 KB |
Output is correct |
37 |
Correct |
59 ms |
19012 KB |
Output is correct |
38 |
Correct |
69 ms |
19644 KB |
Output is correct |
39 |
Correct |
63 ms |
19492 KB |
Output is correct |
40 |
Correct |
56 ms |
18524 KB |
Output is correct |
41 |
Correct |
52 ms |
16696 KB |
Output is correct |
42 |
Correct |
86 ms |
17468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
85 ms |
20700 KB |
Output is correct |
2 |
Correct |
90 ms |
23608 KB |
Output is correct |
3 |
Correct |
89 ms |
22848 KB |
Output is correct |
4 |
Correct |
97 ms |
24632 KB |
Output is correct |
5 |
Correct |
83 ms |
24124 KB |
Output is correct |
6 |
Correct |
80 ms |
21052 KB |
Output is correct |
7 |
Correct |
93 ms |
20280 KB |
Output is correct |
8 |
Correct |
6 ms |
5712 KB |
Output is correct |
9 |
Correct |
6 ms |
5712 KB |
Output is correct |
10 |
Correct |
5 ms |
5712 KB |
Output is correct |
11 |
Correct |
6 ms |
5684 KB |
Output is correct |
12 |
Correct |
6 ms |
5712 KB |
Output is correct |
13 |
Correct |
6 ms |
5712 KB |
Output is correct |
14 |
Correct |
6 ms |
5712 KB |
Output is correct |
15 |
Correct |
6 ms |
5712 KB |
Output is correct |
16 |
Correct |
5 ms |
5712 KB |
Output is correct |
17 |
Correct |
6 ms |
5712 KB |
Output is correct |
18 |
Correct |
5 ms |
5612 KB |
Output is correct |
19 |
Correct |
6 ms |
5712 KB |
Output is correct |
20 |
Correct |
5 ms |
5880 KB |
Output is correct |
21 |
Correct |
6 ms |
5884 KB |
Output is correct |
22 |
Correct |
11 ms |
6476 KB |
Output is correct |
23 |
Correct |
10 ms |
6732 KB |
Output is correct |
24 |
Correct |
9 ms |
6512 KB |
Output is correct |
25 |
Correct |
9 ms |
6676 KB |
Output is correct |
26 |
Correct |
11 ms |
6732 KB |
Output is correct |
27 |
Correct |
10 ms |
6480 KB |
Output is correct |
28 |
Correct |
10 ms |
6480 KB |
Output is correct |
29 |
Correct |
11 ms |
6476 KB |
Output is correct |
30 |
Correct |
10 ms |
6476 KB |
Output is correct |
31 |
Correct |
12 ms |
6476 KB |
Output is correct |
32 |
Correct |
10 ms |
6704 KB |
Output is correct |
33 |
Correct |
10 ms |
6732 KB |
Output is correct |
34 |
Correct |
10 ms |
6480 KB |
Output is correct |
35 |
Correct |
10 ms |
6648 KB |
Output is correct |
36 |
Correct |
63 ms |
17472 KB |
Output is correct |
37 |
Correct |
80 ms |
19748 KB |
Output is correct |
38 |
Correct |
66 ms |
19232 KB |
Output is correct |
39 |
Correct |
68 ms |
19932 KB |
Output is correct |
40 |
Correct |
75 ms |
19520 KB |
Output is correct |
41 |
Correct |
64 ms |
17708 KB |
Output is correct |
42 |
Correct |
80 ms |
17700 KB |
Output is correct |
43 |
Correct |
54 ms |
16540 KB |
Output is correct |
44 |
Correct |
59 ms |
19012 KB |
Output is correct |
45 |
Correct |
69 ms |
19644 KB |
Output is correct |
46 |
Correct |
63 ms |
19492 KB |
Output is correct |
47 |
Correct |
56 ms |
18524 KB |
Output is correct |
48 |
Correct |
52 ms |
16696 KB |
Output is correct |
49 |
Correct |
86 ms |
17468 KB |
Output is correct |
50 |
Correct |
89 ms |
21900 KB |
Output is correct |
51 |
Correct |
158 ms |
39056 KB |
Output is correct |
52 |
Correct |
144 ms |
38192 KB |
Output is correct |
53 |
Correct |
146 ms |
37928 KB |
Output is correct |
54 |
Correct |
148 ms |
42740 KB |
Output is correct |
55 |
Correct |
160 ms |
34788 KB |
Output is correct |
56 |
Correct |
185 ms |
33240 KB |
Output is correct |
57 |
Correct |
33 ms |
10820 KB |
Output is correct |
58 |
Correct |
169 ms |
36916 KB |
Output is correct |
59 |
Correct |
161 ms |
37416 KB |
Output is correct |
60 |
Correct |
157 ms |
41000 KB |
Output is correct |
61 |
Correct |
164 ms |
36908 KB |
Output is correct |
62 |
Correct |
33 ms |
11048 KB |
Output is correct |
63 |
Correct |
163 ms |
33320 KB |
Output is correct |