Submission #1305448

#TimeUsernameProblemLanguageResultExecution timeMemory
1305448tin_leDrawing (CEOI22_drawing)C++20
100 / 100
118 ms20788 KiB
#include<bits/stdc++.h> using namespace std; #define all(x) begin(x), end(x) #define ub upper_bound #define lb lower_bound #define ll long long #define vi vector<int> #define vvi vector<vi> #define vll vector<ll> #define pii pair<int, int> #define pll pair<ll, ll> #define vpii vector<pii> #define vpll vector<pll> #define pb push_back #define ff first #define ss second #define sum(x) (ll)accumulate(all(x), 0LL) #define srt(x) sort(all(x)) #define rev(x) reverse(all(x)) #define srtU(x) sort(all(x)), (x).erase(unique(all(x)), (x).end()) #define i128 __int128 #define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) #if defined(LOCAL) && __has_include("debug.h") #include "debug.h" #else #define debug(...) #define startClock #define endClock inline void printMemoryUsage() {} #endif template<class T> using max_heap = priority_queue<T>; template<class T> using min_heap = priority_queue<T, vector<T>, greater<T>>; template<typename T, size_t N> istream& operator>>(istream& is, array<T, N>& arr) { for (size_t i = 0; i < N; i++) { is >> arr[i]; } return is; } template<typename T, size_t N> istream& operator>>(istream& is, vector<array<T, N>>& vec) { for (auto &arr : vec) { is >> arr; } return is; } template<typename T1, typename T2> istream &operator>>(istream& in, pair<T1, T2>& input) { return in >> input.ff >> input.ss; } template<typename T> istream &operator>>(istream &in, vector<T> &v) { for (auto &el : v) in >> el; return in; } mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); void solve() { int n; cin >> n; vvi graph(n + 1); for(int i = 1; i < n; i++) { int u, v; cin >> u >> v; graph[u].pb(v); graph[v].pb(u); } vpii a(n); cin >> a; vi id(n); iota(all(id), 0); sort(all(id), [&](int i, int j) { return a[i].ff == a[j].ff ? a[i].ss < a[j].ss : a[i].ff < a[j].ff; }); int iter = 0; vi ans(n); auto dfs = [&](auto& dfs, int node = 1, int par = 0) -> void { for(auto& nei : graph[node]) { if(nei == par) continue; dfs(dfs, nei, node); } ans[id[iter++]] = node; }; dfs(dfs); for(auto& x : ans) { cout << x << ' '; } cout << '\n'; } signed main() { IOS; startClock int t = 1; //cin >> t; for(int i = 1; i <= t; i++) { //cout << "Case #" << i << ": "; solve(); } endClock; printMemoryUsage(); return 0; }
#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...