Submission #307694

#TimeUsernameProblemLanguageResultExecution timeMemory
307694CodePlatinaStations (IOI20_stations)C++14
0 / 100
3056 ms2097156 KiB
#include "stations.h" #include <vector> using namespace std; vector<int> gph[1010]; int ord[1010]; int cnt = 0; void dfs(int x, int p, bool flag) { if(flag) ord[x] = ++cnt; for(auto y : gph[x]) if(y != p) dfs(y, x, !flag); if(!flag) ord[x] = ++cnt; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { vector<int> labels(n); for(int i = 0; i < n; ++i) ord[i] = 0; cnt = 0; for(int i = 0; i < n - 1; ++i) { gph[u[i]].push_back(v[i]); gph[v[i]].push_back(u[i]); } dfs(0, 0, false); for(int i = 0; i < n; ++i) labels[i] = ord[i]; return labels; } int find_next_station(int s, int t, vector<int> c) { int n = c.size(); if(s < c[0]) { int pr = s; for(int i = 0; i < n - 1; ++i) { if(pr < t && t <= c[i]) return c[i]; pr = c[i]; } return c[n - 1]; } else { int pr = s; for(int i = n - 1; i >= 1; --i) { if(c[i] <= t && t < pr) return c[i]; pr = c[i]; } 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...