Submission #624958

#TimeUsernameProblemLanguageResultExecution timeMemory
624958prvocisloStations (IOI20_stations)C++17
0 / 100
793 ms780 KiB
#include "stations.h" #include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <string> #include <vector> typedef long long ll; typedef long double ld; using namespace std; const int maxn = 1e3 + 5; vector<int> g[maxn]; int tin[maxn], tout[maxn], t = 0; vector<int> l; void dfs(int u, int d, int p = -1) { tin[u] = t++; for (int v : g[u]) if (v != p) dfs(v, d ^ 1, u), t++; tout[u] = t - 1; if (d) l[u] = tout[u]; else l[u] = tin[u]; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { t = 0; for (int i = 0; i < n; i++) g[i].clear(), tin[i] = tout[i] = 0; for (int i = 0; i < n - 1; i++) g[u[i]].push_back(v[i]), g[v[i]].push_back(u[i]); l.assign(n, 0); dfs(0, 0); return l; } int find_next_station(int s, int t, vector<int> c) { int k = c.size(); if (s <= c[0]) // ja som tin, c-cka su tout { int tin = s; int tout = (s ? (k > 1 ? c[k - 2] + 1 : s) : c.back()); if (t < tin || t > tout) return c[k - 1]; // v tomto podstrome nie je t, musim ist do rodica int i = 0; while (i + 1 < k && t <= c[i + 1]) i++; return c[i]; } else // ja som tout, c-cka su tin { int tin = (k > 1 ? c[1] - 1 : s); int tout = s; if (t < tin || t > tout) return c[0]; // v tomto podstrome nie je t, musim ist do rodica int i = 0; while (i + 1 < k && c[i + 1] <= t) i++; return c[i]; } }
#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...