Submission #772445

#TimeUsernameProblemLanguageResultExecution timeMemory
772445SanguineChameleonStations (IOI20_stations)C++17
0 / 100
3 ms456 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; const int maxn = 1e3 + 20; vector<int> adj[maxn]; int tin[maxn]; int tout[maxn]; int t = -1; void dfs(int u, int p) { tin[u] = ++t; for (auto v: adj[u]) { if (v != p) { dfs(v, u); } } tout[u] = t; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { for (int i = 0; i < n - 1; i++) { adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } //dfs(0, -1); vector<int> labels(n); for (int i = 0; i < n; i++) { labels[i] = tin[i] * 1000 + tout[i]; } return labels; } int find_next_station(int s, int t, vector<int> c) { int tin_s = s / 1000; int tout_s = s % 1000; int tin_t = t / 1000; int tout_t = t % 1000; int par = -1; for (auto u: c) { int tin_u = u / 1000; int tout_u = u % 1000; if (tin_u <= tin_s && tout_s <= tout_u) { par = u; } else if (tin_u <= tin_t && tout_t <= tout_u) { return u; } } return par; }
#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...