Submission #535370

#TimeUsernameProblemLanguageResultExecution timeMemory
535370pokmui9909Stations (IOI20_stations)C++17
0 / 100
734 ms528 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; using ll = long long; vector<int> num; ll cnt = 0; vector<ll> G[1005]; void DFS(ll u, ll p){ if(p == -1 || !num[p]) num[u] = ++cnt; for(auto v : G[u]){ if(v == p) continue; DFS(v, u); } if(!num[u]) num[u] = ++cnt; } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { num.resize(n, 0); for(int i = 0; i < n; i++) G[i].clear(); cnt = 0; for(int i = 0; i < n - 1; i++){ G[u[i]].push_back(v[i]); G[v[i]].push_back(u[i]); } DFS(0, -1); return num; } int find_next_station(int s, int t, std::vector<int> c) { if(c.back() < s) reverse(c.begin(), c.end()); for(auto v : c){ if(min(s, v) <= t && t <= max(s, v)){ return v; } } return c.back(); }
#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...