Submission #620570

#TimeUsernameProblemLanguageResultExecution timeMemory
620570wiwihoStations (IOI20_stations)C++14
5 / 100
891 ms676 KiB
#include "stations.h" #include <bits/stdc++.h> #define iter(a) a.begin(), a.end() #define lsort(a) sort(iter(a)) #define gsort(a) sort(iter(a), greater<>()) #define eb emplace_back #define ef emplace_front #define pob pop_back() #define pof pop_front() #define mp make_pair #define F first #define S second #define uni(a) a.resize(unique(iter(a)) - a.begin()) #define printv(a, b) { \ for(auto pv : a) b << pv << " "; \ b << "\n"; \ } using namespace std; typedef long long ll; typedef long double ld; using pii = pair<int, int>; using pll = pair<ll, ll>; template<typename A, typename B> ostream& operator<<(ostream& o, pair<A, B> p){ return o << '(' << p.F << ',' << p.S << ')'; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { vector<vector<int>> g(n); vector<int> ans(n); int ts = -1; function<void(int, int, int)> dfs = [&](int now, int p, int d){ int in = ++ts; for(int i : g[now]){ if(i == p) continue; dfs(i, now, d + 1); } ans[now] = in; }; for(int i = 0; i < n - 1; i++){ g[u[i]].eb(v[i]); g[v[i]].eb(u[i]); } for(int i = 0; i < n; i++){ if(g[i].size() > 1) continue; dfs(i, i, 0); break; } return ans; } int find_next_station(int s, int t, vector<int> c) { if(c.size() == 1) return c[0]; if(s < t){ return c[1]; } else{ return c[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...