Submission #644864

#TimeUsernameProblemLanguageResultExecution timeMemory
644864Do_you_copyDrawing (CEOI22_drawing)C++17
100 / 100
284 ms38264 KiB
//////////////////////////// // Gke vay sao // //////////////////////////// #include <bits/stdc++.h> #define int long long #define fi first #define se second #define pb push_back #define faster ios_base::sync_with_stdio(0); cin.tie(0); using namespace std; using ll = long long; using ull = unsigned ll; using ld = long double; using pii = pair <int, int>; using pil = pair <int, ll>; using pli = pair <ll, int>; using pll = pair <ll, ll>; mt19937 Rand(chrono::steady_clock::now().time_since_epoch().count()); ll min(const ll &a, const ll &b){ return (a < b) ? a : b; } ll max(const ll &a, const ll &b){ return (a > b) ? a : b; } //const ll Mod = 1000000007; //const ll Mod2 = 999999999989; //only use when required const int maxN = 3e5 + 1; int n; struct TPoint{ int x, y, idx; }; TPoint p[maxN]; vector <int> adj[maxN]; int sz[maxN]; int ans[maxN]; int x, y; void pre_dfs(int u, int par){ sz[u] = 1; for (int i: adj[u]){ if (i == par) continue; pre_dfs(i, u); sz[u] += sz[i]; } } void dfs(int u, int par, int idx){ ans[p[idx].idx] = u; int tem = idx + 1; for (int i: adj[u]){ if (i == par) continue; dfs(i, u, tem); tem += sz[i]; } } void Init(){ cin >> n; for (int i = 1; i < n; ++i){ int u, v; cin >> u >> v; adj[u].pb(v); adj[v].pb(u); } pre_dfs(1, 0); for (int i = 1; i <= n; ++i){ cin >> p[i].x >> p[i].y; p[i].idx = i; } if (n == 1){ cout << 1; return; } sort(p + 1, p + n + 1,[](const auto &i, const auto &j){ //left bottom if (i.x == j.x) return i.y < j.y; return i.x < j.x; }); x = p[1].x; y = p[1].y; sort(p + 2, p + n + 1,[&](const auto &i, const auto &j){ //cross product return x * i.y - i.x * y > x * j.y - j.x * y; }); dfs(1, 0, 1); for (int i = 1; i <= n; ++i) cout << ans[i] << " "; } #define debu #define taskname "test" signed main(){ if (fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); #ifdef debug freopen(taskname".out", "w", stdout); #endif } faster; ll tt = 1; //cin >> tt; while (tt--){ Init(); } #ifdef debug ofstream timeout("timeout.txt"); timeout << signed(1000 * double(clock()) / CLOCKS_PER_SEC); timeout.close(); #else cerr << "\nTime elapsed: " << 1000 * double(clock()) / CLOCKS_PER_SEC << "ms\n"; #endif }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:97:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   97 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...