Submission #864706

#TimeUsernameProblemLanguageResultExecution timeMemory
864706mychecksedadDrawing (CEOI22_drawing)C++17
30 / 100
1534 ms33896 KiB
/* 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; void dfs(int v, int p){ s[v] = 1; for(int u: g[v]){ if(u != p) dfs(u, v), s[v] += s[u]; } } void dfs2(int v, int par, Poly &p, int l){ pos[p.poly[l].second] = v; vis[p.poly[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; } } } } dfs2(u, v, p, po); } } 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); } Poly p(n); // p.ch(); // assert(p.poly.size()==n); // for(auto pp: p.poly){ // cout << pp.first.x << ' ' << pp.first.y << ' ' << pp.second << '\n'; // } sort(all(p.poly)); vis.resize(n); dfs(1, 1); dfs2(1, 1, p, 0); for(int i = 0; i < n; ++i) cout << pos[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 (stderr)

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:109:15: warning: unused variable 'aa' [-Wunused-variable]
  109 |   int tt = 1, aa;
      |               ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...