Submission #741088

#TimeUsernameProblemLanguageResultExecution timeMemory
741088siewjhStations (IOI20_stations)C++17
0 / 100
807 ms672 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 1005; vector<int> adj[MAXN], lbls; int ind; void dfs(int x, int par, bool typ){ if (typ) lbls[x] = ++ind; for (int nxt : adj[x]){ if (nxt == par) continue; dfs(nxt, x, !typ); } if (!typ) lbls[x] = ++ind; } vector<int> label(int nodes, int maxlbl, vector<int> u, vector<int> v) { for (int i = 0; i < nodes; i++) adj[i].clear(); for (int i = 0; i < nodes - 1; i++){ int a = u[i], b = v[i]; adj[a].push_back(b); adj[b].push_back(a); } lbls = vector<int>(nodes, -1); ind = -1; dfs(0, -1, 1); return lbls; } int find_next_station(int s, int t, vector<int> c) { if (s < c[0]){ if (t < s) return c.back(); else return *lower_bound(c.begin(), c.end(), t); } else{ if (t > s) return c[0]; else return *(upper_bound(c.begin(), c.end(), t) - 1); } }
#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...