Submission #591797

#TimeUsernameProblemLanguageResultExecution timeMemory
591797SirCovidThe19thStations (IOI20_stations)C++17
0 / 100
3157 ms2097152 KiB
#include <bits/stdc++.h> using namespace std; int ti; vector<int> ans, adj[1005]; void dfs(int i, int dep, int p){ if (dep % 2 == 0) ans[i] = ti++; for (int to : adj[i]) if (to != p) dfs(to, dep + 1, i); if (dep % 2 == 1) ans[i] = ti++; } vector<int> label(int n, int k, vector<int> u, vector<int> v){ for (int i = 0; i < n; i++) adj[i].clear(); ans.assign(n, 0); for (int i = 0; i < n; i++){ adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } dfs(0, 0, -1); return ans; } int find_next_station(int s, int t, vector<int> c){ if (s > c[0]){ //tout layer if (t < c[0] or t > s) return c[0]; return *prev(upper_bound(c.begin(), c.end(), t)); } else{ //tin layer if (t < s or t > c.back()) return c.back(); return *lower_bound(c.begin(), c.end(), t); } }
#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...