Submission #1111960

#TimeUsernameProblemLanguageResultExecution timeMemory
1111960MisterReaperDrawing (CEOI22_drawing)C++17
100 / 100
194 ms34380 KiB
#include <bits/stdc++.h> using i64 = long long; #ifdef DEBUG #include "../../debug.h" #else #define debug(...) void(23) #endif constexpr int max_N = int(2E5) + 5; int N; int A[max_N], B[max_N], ans[max_N]; std::vector<int> adj[max_N]; int cur = 0; std::vector<int> p; void solve(int v) { ans[v] = p[cur++]; for (auto u : adj[v]) { adj[u].erase(std::find(adj[u].begin(), adj[u].end(), v)); solve(u); } } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); std::cin >> N; for (int i = 0; i < N - 1; ++i) { int u, v; std::cin >> u >> v; --u, --v; adj[u].emplace_back(v); adj[v].emplace_back(u); } for (int i = 0; i < N; ++i) { std::cin >> A[i] >> B[i]; ++A[i], ++B[i]; } p.assign(N, 0); std::iota(p.begin(), p.end(), 0); std::sort(p.begin(), p.end(), [&](auto lhs, auto rhs) { return std::pair{A[lhs], B[lhs]} < std::pair{A[rhs], B[rhs]}; }); solve(0); for (int i = 0; i < N; ++i) { std::cout << ans[i] + 1 << " \n"[i == N - 1]; } 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...