Submission #673712

#TimeUsernameProblemLanguageResultExecution timeMemory
673712vjudge1Stations (IOI20_stations)C++17
10 / 100
904 ms620 KiB
#include <vector> //#include "IOI20_Stations.h" const int N = 1000; int cnt=0; std::vector<int> labels; /* clarifications: k == n-1 c is sorted */ std::vector<std::vector<int>> g; void dfs(int node, int par) { labels[node] = cnt++; for (int ch : g[node]) { if (ch != par) { dfs(ch, node); } } labels[node] += N * (cnt++); } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { /* 1. Construct adjacency list 2. Label every node with its mrg(dt,ft) */ g.clear(); g.resize(n); for (int i = 0; i < n - 1;i++) { g[u[i]].push_back(v[i]); g[v[i]].push_back(u[i]); } cnt = 0; labels.clear(); labels.resize(n); dfs(0, -1); return labels; } int find_next_station(int s, int t, std::vector<int> c) { int sz = c.size(); for (int i = 0; i < sz-1; i++) { // The destination is under this child, Because it's impossible that it was discovered after that, or before that if (t%N >= c[i]%N && t%N < c[i]/N) 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...