Submission #835126

#TimeUsernameProblemLanguageResultExecution timeMemory
835126andrey27_smStations (IOI20_stations)C++17
0 / 100
724 ms548 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; vector<int> G[1001]; int tin[1001]; int tout[1001]; int level[1001]; int T; void dfs(int v,int p = -1){ if(p != -1) level[v] = level[p]+1; tin[v] = T++; for(auto e:G[v]){ if(e == p) continue; dfs(e,v); } tout[v] = T; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { T = 0; for (int i = 0; i < n; ++i) { G[i].clear(); } for (int i = 0; i < n-1; ++i) { G[u[i]].push_back(v[i]); G[v[i]].push_back(u[i]); } int root = 0; while(G[root].size() != 1) root++; dfs(root); vector<int> labels; for (int i = 0; i < n; ++i) { labels.push_back(tin[i]); } return labels; } int find_next_station(int s, int t, vector<int> c) { sort(c.begin(), c.end()); if(t > s) 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...