Submission #864696

# Submission time Handle Problem Language Result Execution time Memory
864696 2023-10-23T13:06:28 Z mychecksedad Drawing (CEOI22_drawing) C++17
10 / 100
96 ms 45244 KB
/* 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>{x,y}<array<ll,2>{other.x,other.y};
  }
};
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];
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;
  int cur = l + 1;
  for(int u: g[v]){
    if(u==par) continue;
    dfs2(u, v, p, cur);
    cur += s[u];
  }
}
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';
  // }
  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

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:94:15: warning: unused variable 'aa' [-Wunused-variable]
   94 |   int tt = 1, aa;
      |               ^~
# Verdict Execution time Memory Grader output
1 Correct 77 ms 38084 KB Output is correct
2 Correct 81 ms 43100 KB Output is correct
3 Correct 78 ms 40716 KB Output is correct
4 Correct 96 ms 45176 KB Output is correct
5 Correct 82 ms 45244 KB Output is correct
6 Correct 75 ms 39368 KB Output is correct
7 Correct 79 ms 39684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 27672 KB Output is correct
2 Incorrect 8 ms 27740 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 27672 KB Output is correct
2 Incorrect 8 ms 27740 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 27672 KB Output is correct
2 Incorrect 8 ms 27740 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 77 ms 38084 KB Output is correct
2 Correct 81 ms 43100 KB Output is correct
3 Correct 78 ms 40716 KB Output is correct
4 Correct 96 ms 45176 KB Output is correct
5 Correct 82 ms 45244 KB Output is correct
6 Correct 75 ms 39368 KB Output is correct
7 Correct 79 ms 39684 KB Output is correct
8 Correct 8 ms 27672 KB Output is correct
9 Incorrect 8 ms 27740 KB Output isn't correct
10 Halted 0 ms 0 KB -