Submission #1024352

#TimeUsernameProblemLanguageResultExecution timeMemory
1024352Ahmed_SolymanStations (IOI20_stations)C++14
0 / 100
3070 ms684 KiB
#include <bits/stdc++.h> using namespace std; #include "stations.h" typedef long long ll; vector<vector<int>>adj; vector<int>ret; void dfs(int node,int mark=0,int par=-1){ if(mark>1000){ return; } ret[node]=mark; for(auto i:adj[node]){ if(i!=par)dfs(i,mark+1,node); } } vector<int> label(int n, int k, vector<int> u, vector<int> v){ ret.resize(n); adj.resize(n); for(int i=0;i<n-1;i++){ adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } int root=0; for(int i=0;i<n;i++){ if(adj[i].size()==1)root=i; } dfs(root,root); return ret; } int find_next_station(int s, int t,vector<int> c){ if (c.size() == 1) return c[0]; for (int l : c) if (l == t) return t; if (t > s) return c.back(); 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...