Submission #634312

#TimeUsernameProblemLanguageResultExecution timeMemory
634312tabrStations (IOI20_stations)C++17
0 / 100
5 ms888 KiB
#include <bits/stdc++.h> using namespace std; #ifdef tabr #include "library/debug.cpp" #else #define debug(...) #endif // editorial? vector<int> label(int n, int k, vector<int> x, vector<int> y) { vector<vector<int>> g(n); for (int i = 0; i < n - 1; i++) { g[x[i]].emplace_back(y[i]); g[y[i]].emplace_back(x[i]); } vector<int> in(n), out(n), order; function<void(int, int)> Dfs = [&](int v, int p) { in[v] = (int) order.size(); order.emplace_back(v); for (int to : g[v]) { if (to == p) { continue; } Dfs(to, v); } out[v] = (int) order.size(); }; Dfs(0, -1); vector<int> res(n); for (int i = 0; i < n; i++) { res[i] = out[i] * 1000 + in[i]; } return res; } int find_next_station(int s, int t, vector<int> c) { int t_in = t % 1000; sort(c.begin(), c.end(), [&](int i, int j) { return i % 1000 > j % 1000; }); for (int v : c) { int v_in = v % 1000; int v_out = v / 1000; if (v_in < t_in && t_in < v_out) { return v; } } assert(false); return -1; } #ifdef tabr int main() { ios::sync_with_stdio(false); cin.tie(0); return 0; } #endif
#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...