Submission #819806

#TimeUsernameProblemLanguageResultExecution timeMemory
819806Alihan_8기지국 (IOI20_stations)C++17
0 / 100
3 ms920 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define pb push_back #define ln '\n' //#define int long long template <class _T> bool chmin(_T &x, const _T &y){ bool flag = false; if ( x > y ){ x = y; flag |= true; } return flag; } template <class _T> bool chmax(_T &x, const _T &y){ bool flag = false; if ( x < y ){ x = y; flag |= true; } return flag; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { vector <int> g[n], d(n, -1), tin(n), tout(n); for ( int i = 0; i + 1 < n; i++ ){ g[u[i]].pb(v[i]); g[v[i]].pb(u[i]); } int timer = 1; function <void(int)> dfs = [&](int x){ tin[x] = timer++; for ( auto to: g[x] ){ if ( d[to] == -1 ){ d[to] = d[x] + 1; dfs(to); } } tout[x] = timer++; }; d[0] = 1; dfs(0); vector <int> ans(n); for ( int i = 0; i < n; i++ ){ ans[i] = d[i] & 1 ? tin[i] : tout[i]; } return ans; } int find_next_station(int s, int t, vector<int> c) { int n = (int)c.size(); if ( c[0] >= s ){ // tin int tin = s, tout = s != 1 ? c[n - 2] + 1 : c[n - 1] + 1; if ( tin < t and tout > t ){ for ( auto &x: c ){ if ( x > t ){ return x; } } assert(false); } else{ return c[n - 1]; } } else{ int tin = c[0] + 1, tout = s; if ( tin < t and tout > t ){ for ( int i = n - 1; i >= 0; i-- ){ if ( c[i] < t ){ return c[i]; } } assert(false); } else{ return tin - 1; } } return -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...