/* Author : Mychecksdead */
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
const int N = 1e6+100, M = 1e5+10, K = 52, MX = 30;
struct P{
ll x, y;
void read(){
cin >> x >> y;
}
ll operator * (const P &other) const{
return x * other.y - y * other.x;
}
P operator - (const P &other) const{
return P{x-other.x, y-other.y};
}
bool operator < (const P&other)const{
return array<ll,2>{y,-x}>array<ll,2>{other.y,-other.x};
}
};
struct Poly{
vector<pair<P, int>> poly;
Poly(int n){
poly.resize(n);
for(int i = 0; i < n; ++i)
poly[i].first.read(), poly[i].second = i;
}
void ch(){
sort(all(poly));
vector<pair<P, int>> c;
for(int i = 0; i < poly.size(); ++i){
while(c.size() > 1 && (poly[i].first - c[c.size() - 2].first) * (c.back().first - c[c.size() - 2].first) < 0) c.pop_back();
c.pb(poly[i]);
}
c.pop_back();
reverse(all(poly));
for(int i = 0; i < poly.size(); ++i){
while(c.size() > 1 && (poly[i].first - c[c.size() - 2].first) * (c.back().first - c[c.size() - 2].first) < 0) c.pop_back();
c.pb(poly[i]);
}
c.pop_back();
poly = c;
}
};
int n, s[N], pos[N];
vector<int> g[N];
vector<bool> vis, used;
void dfs(int v, int p){
s[v] = 1;
for(int u: g[v]){
if(u != p) dfs(u, v), s[v] += s[u];
}
}
// int cen(int v, int p){
// for(int u: g[v]){
// if(u==p||used[u]) continue
// if(s[u] > s[v]-s[u]) return cen(u, v);
// }
// return v;
// }
// void centroid(int v, vector<pair<P, int>> &v){
// pre(v, v);
// int centro = cen(v, v);
// sort(all(v));
// pos[v[0].second] = v;
// sort(v.begin() + 1, v.end(), [&](const pair<P, int> &x, const pair<P, int> &y){
// return (x.first - v[0].first) * (y.first - v[0].first) < 0;
// });
// }
void dfs2(int v, int par, vector<pair<P, int>> &p, int &l){
pos[p[l].second] = v;
vis[p[l].second] = 1;
// cout << v << ' ' << par << '\n';
// cout << p.poly[l].second << '\n';
for(int u: g[v]){
if(u==par) continue;
// int po = -1;
// for(int i = 0; i < n; ++i){
// if(!vis[p.poly[i].second]){
// if(po == -1) po = i;
// else{
// if((p.poly[po].first - p.poly[l].first) * (p.poly[i].first - p.poly[l].first) > 0){
// po = i;
// }
// }
// }
// }
++l;
dfs2(u, v, p, l);
}
}
void solve(){
cin >> n;
for(int i = 0; i < n-1; ++i){
int u, v; cin >> u >> v;
g[u].pb(v);
g[v].pb(u);
}
vector<pair<P, int>> v(n);
for(int i = 0; i < n; ++i){
v[i].first.read();
v[i].second = i;
}
for(int i = 0; i < n; ++i){
cout << n-i << ' ';
}
}
int main(){
cin.tie(0); ios::sync_with_stdio(0);
int tt = 1, aa;
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
while(tt--){
solve();
}
cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n";
return 0;
}
Compilation message
Main.cpp: In member function 'void Poly::ch()':
Main.cpp:38:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<P, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
38 | for(int i = 0; i < poly.size(); ++i){
| ~~^~~~~~~~~~~~~
Main.cpp:44:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<P, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
44 | for(int i = 0; i < poly.size(); ++i){
| ~~^~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:123:15: warning: unused variable 'aa' [-Wunused-variable]
123 | int tt = 1, aa;
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
55 ms |
32084 KB |
Output is correct |
2 |
Correct |
55 ms |
32080 KB |
Output is correct |
3 |
Correct |
54 ms |
32084 KB |
Output is correct |
4 |
Correct |
59 ms |
32848 KB |
Output is correct |
5 |
Correct |
59 ms |
31824 KB |
Output is correct |
6 |
Correct |
54 ms |
32088 KB |
Output is correct |
7 |
Correct |
53 ms |
32092 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
25436 KB |
Output is correct |
2 |
Correct |
7 ms |
25432 KB |
Output is correct |
3 |
Correct |
7 ms |
25432 KB |
Output is correct |
4 |
Correct |
6 ms |
25436 KB |
Output is correct |
5 |
Correct |
7 ms |
25436 KB |
Output is correct |
6 |
Correct |
8 ms |
25436 KB |
Output is correct |
7 |
Correct |
7 ms |
25436 KB |
Output is correct |
8 |
Correct |
7 ms |
25436 KB |
Output is correct |
9 |
Correct |
9 ms |
25692 KB |
Output is correct |
10 |
Correct |
7 ms |
25432 KB |
Output is correct |
11 |
Correct |
7 ms |
25436 KB |
Output is correct |
12 |
Correct |
7 ms |
25436 KB |
Output is correct |
13 |
Correct |
7 ms |
25436 KB |
Output is correct |
14 |
Correct |
9 ms |
25436 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
25436 KB |
Output is correct |
2 |
Correct |
7 ms |
25432 KB |
Output is correct |
3 |
Correct |
7 ms |
25432 KB |
Output is correct |
4 |
Correct |
6 ms |
25436 KB |
Output is correct |
5 |
Correct |
7 ms |
25436 KB |
Output is correct |
6 |
Correct |
8 ms |
25436 KB |
Output is correct |
7 |
Correct |
7 ms |
25436 KB |
Output is correct |
8 |
Correct |
7 ms |
25436 KB |
Output is correct |
9 |
Correct |
9 ms |
25692 KB |
Output is correct |
10 |
Correct |
7 ms |
25432 KB |
Output is correct |
11 |
Correct |
7 ms |
25436 KB |
Output is correct |
12 |
Correct |
7 ms |
25436 KB |
Output is correct |
13 |
Correct |
7 ms |
25436 KB |
Output is correct |
14 |
Correct |
9 ms |
25436 KB |
Output is correct |
15 |
Correct |
10 ms |
25692 KB |
Output is correct |
16 |
Correct |
10 ms |
25688 KB |
Output is correct |
17 |
Correct |
10 ms |
25692 KB |
Output is correct |
18 |
Correct |
9 ms |
25688 KB |
Output is correct |
19 |
Correct |
9 ms |
25692 KB |
Output is correct |
20 |
Correct |
9 ms |
25692 KB |
Output is correct |
21 |
Correct |
9 ms |
25824 KB |
Output is correct |
22 |
Correct |
9 ms |
25688 KB |
Output is correct |
23 |
Correct |
9 ms |
25944 KB |
Output is correct |
24 |
Correct |
9 ms |
25692 KB |
Output is correct |
25 |
Correct |
9 ms |
25692 KB |
Output is correct |
26 |
Correct |
10 ms |
25692 KB |
Output is correct |
27 |
Correct |
9 ms |
25692 KB |
Output is correct |
28 |
Correct |
9 ms |
25692 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
25436 KB |
Output is correct |
2 |
Correct |
7 ms |
25432 KB |
Output is correct |
3 |
Correct |
7 ms |
25432 KB |
Output is correct |
4 |
Correct |
6 ms |
25436 KB |
Output is correct |
5 |
Correct |
7 ms |
25436 KB |
Output is correct |
6 |
Correct |
8 ms |
25436 KB |
Output is correct |
7 |
Correct |
7 ms |
25436 KB |
Output is correct |
8 |
Correct |
7 ms |
25436 KB |
Output is correct |
9 |
Correct |
9 ms |
25692 KB |
Output is correct |
10 |
Correct |
7 ms |
25432 KB |
Output is correct |
11 |
Correct |
7 ms |
25436 KB |
Output is correct |
12 |
Correct |
7 ms |
25436 KB |
Output is correct |
13 |
Correct |
7 ms |
25436 KB |
Output is correct |
14 |
Correct |
9 ms |
25436 KB |
Output is correct |
15 |
Correct |
10 ms |
25692 KB |
Output is correct |
16 |
Correct |
10 ms |
25688 KB |
Output is correct |
17 |
Correct |
10 ms |
25692 KB |
Output is correct |
18 |
Correct |
9 ms |
25688 KB |
Output is correct |
19 |
Correct |
9 ms |
25692 KB |
Output is correct |
20 |
Correct |
9 ms |
25692 KB |
Output is correct |
21 |
Correct |
9 ms |
25824 KB |
Output is correct |
22 |
Correct |
9 ms |
25688 KB |
Output is correct |
23 |
Correct |
9 ms |
25944 KB |
Output is correct |
24 |
Correct |
9 ms |
25692 KB |
Output is correct |
25 |
Correct |
9 ms |
25692 KB |
Output is correct |
26 |
Correct |
10 ms |
25692 KB |
Output is correct |
27 |
Correct |
9 ms |
25692 KB |
Output is correct |
28 |
Correct |
9 ms |
25692 KB |
Output is correct |
29 |
Correct |
40 ms |
30044 KB |
Output is correct |
30 |
Correct |
40 ms |
30040 KB |
Output is correct |
31 |
Correct |
40 ms |
29908 KB |
Output is correct |
32 |
Correct |
40 ms |
30036 KB |
Output is correct |
33 |
Correct |
39 ms |
30288 KB |
Output is correct |
34 |
Correct |
40 ms |
29908 KB |
Output is correct |
35 |
Correct |
39 ms |
30036 KB |
Output is correct |
36 |
Correct |
35 ms |
29264 KB |
Output is correct |
37 |
Correct |
40 ms |
30032 KB |
Output is correct |
38 |
Correct |
40 ms |
30104 KB |
Output is correct |
39 |
Correct |
39 ms |
30044 KB |
Output is correct |
40 |
Correct |
38 ms |
29912 KB |
Output is correct |
41 |
Correct |
35 ms |
29276 KB |
Output is correct |
42 |
Correct |
40 ms |
30044 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
55 ms |
32084 KB |
Output is correct |
2 |
Correct |
55 ms |
32080 KB |
Output is correct |
3 |
Correct |
54 ms |
32084 KB |
Output is correct |
4 |
Correct |
59 ms |
32848 KB |
Output is correct |
5 |
Correct |
59 ms |
31824 KB |
Output is correct |
6 |
Correct |
54 ms |
32088 KB |
Output is correct |
7 |
Correct |
53 ms |
32092 KB |
Output is correct |
8 |
Correct |
7 ms |
25436 KB |
Output is correct |
9 |
Correct |
7 ms |
25432 KB |
Output is correct |
10 |
Correct |
7 ms |
25432 KB |
Output is correct |
11 |
Correct |
6 ms |
25436 KB |
Output is correct |
12 |
Correct |
7 ms |
25436 KB |
Output is correct |
13 |
Correct |
8 ms |
25436 KB |
Output is correct |
14 |
Correct |
7 ms |
25436 KB |
Output is correct |
15 |
Correct |
7 ms |
25436 KB |
Output is correct |
16 |
Correct |
9 ms |
25692 KB |
Output is correct |
17 |
Correct |
7 ms |
25432 KB |
Output is correct |
18 |
Correct |
7 ms |
25436 KB |
Output is correct |
19 |
Correct |
7 ms |
25436 KB |
Output is correct |
20 |
Correct |
7 ms |
25436 KB |
Output is correct |
21 |
Correct |
9 ms |
25436 KB |
Output is correct |
22 |
Correct |
10 ms |
25692 KB |
Output is correct |
23 |
Correct |
10 ms |
25688 KB |
Output is correct |
24 |
Correct |
10 ms |
25692 KB |
Output is correct |
25 |
Correct |
9 ms |
25688 KB |
Output is correct |
26 |
Correct |
9 ms |
25692 KB |
Output is correct |
27 |
Correct |
9 ms |
25692 KB |
Output is correct |
28 |
Correct |
9 ms |
25824 KB |
Output is correct |
29 |
Correct |
9 ms |
25688 KB |
Output is correct |
30 |
Correct |
9 ms |
25944 KB |
Output is correct |
31 |
Correct |
9 ms |
25692 KB |
Output is correct |
32 |
Correct |
9 ms |
25692 KB |
Output is correct |
33 |
Correct |
10 ms |
25692 KB |
Output is correct |
34 |
Correct |
9 ms |
25692 KB |
Output is correct |
35 |
Correct |
9 ms |
25692 KB |
Output is correct |
36 |
Correct |
40 ms |
30044 KB |
Output is correct |
37 |
Correct |
40 ms |
30040 KB |
Output is correct |
38 |
Correct |
40 ms |
29908 KB |
Output is correct |
39 |
Correct |
40 ms |
30036 KB |
Output is correct |
40 |
Correct |
39 ms |
30288 KB |
Output is correct |
41 |
Correct |
40 ms |
29908 KB |
Output is correct |
42 |
Correct |
39 ms |
30036 KB |
Output is correct |
43 |
Correct |
35 ms |
29264 KB |
Output is correct |
44 |
Correct |
40 ms |
30032 KB |
Output is correct |
45 |
Correct |
40 ms |
30104 KB |
Output is correct |
46 |
Correct |
39 ms |
30044 KB |
Output is correct |
47 |
Correct |
38 ms |
29912 KB |
Output is correct |
48 |
Correct |
35 ms |
29276 KB |
Output is correct |
49 |
Correct |
40 ms |
30044 KB |
Output is correct |
50 |
Correct |
62 ms |
32848 KB |
Output is correct |
51 |
Correct |
94 ms |
37280 KB |
Output is correct |
52 |
Correct |
94 ms |
37496 KB |
Output is correct |
53 |
Correct |
91 ms |
37456 KB |
Output is correct |
54 |
Correct |
120 ms |
37520 KB |
Output is correct |
55 |
Correct |
103 ms |
37492 KB |
Output is correct |
56 |
Correct |
94 ms |
37472 KB |
Output is correct |
57 |
Correct |
24 ms |
27740 KB |
Output is correct |
58 |
Correct |
93 ms |
37460 KB |
Output is correct |
59 |
Correct |
94 ms |
37204 KB |
Output is correct |
60 |
Correct |
92 ms |
37456 KB |
Output is correct |
61 |
Correct |
101 ms |
37484 KB |
Output is correct |
62 |
Correct |
24 ms |
27732 KB |
Output is correct |
63 |
Correct |
93 ms |
37460 KB |
Output is correct |