Submission #306104

#TimeUsernameProblemLanguageResultExecution timeMemory
306104loliconStations (IOI20_stations)C++14
52.32 / 100
1136 ms1280 KiB
#include <bits/stdc++.h> #include "stations.h" using namespace std; vector<int> label(int n, int k, vector<int> u, vector<int> v) { vector<vector<int>> G(n); vector<int> l(n), r(n), ret(n); for(int i = 0; i < n - 1; i++) { G[u[i]].push_back(v[i]); G[v[i]].push_back(u[i]); } int cnt = -1; function<void(int, int)> dfs = [&](int x, int p) { l[x] = ++cnt; for(int y : G[x]) { if(y == p) continue; dfs(y, x); } r[x] = cnt; }; dfs(0, -1); for(int i = 0; i < n; i++) { ret[i] = r[i] * 1000 + l[i]; } return ret; } int find_next_station(int s, int t, vector<int> c) { int sz = c.size(); t = t % 1000; sort(begin(c), end(c), [&](int a, int b){ int la = a % 1000; int ra = a / 1000; int lb = b % 1000; int rb = b / 1000; return (ra - la) < (rb - lb); }); for(int i = 0; i < sz - 1; i++) { int l = c[i] % 1000; int r = c[i] / 1000; if(l <= t && t <= r) return c[i]; } return c[sz - 1]; }
#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...