Submission #780762

#TimeUsernameProblemLanguageResultExecution timeMemory
780762jasminStations (IOI20_stations)C++17
0 / 100
818 ms776 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; void dfs(int v, int p, int& ind, vector<vector<int> >& adi, vector<int>& label){ label[v]=ind; ind++; for(auto u: adi[v]){ if(u==p) continue; dfs(u, v, ind, adi, label); } } vector<int> label(int n, int k, vector<int> u, vector<int> v) { vector<vector<int> > adi(n); for(int i=0; i<n-1; i++){ adi[v[i]].push_back(u[i]); adi[u[i]].push_back(v[i]); } vector<int> labels(n, 0); int ind=0; dfs(0, -1, ind, adi, labels); return labels; } int find_next_station(int s, int t, vector<int> c) { int p=-1; set<int> children; for(auto e: c){ if(e<s){ p=e; } else{ children.insert(e); } } if(t<s){ return p; } int ans = *prev(children.upper_bound(t)); return ans; }
#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...