Submission #416677

#TimeUsernameProblemLanguageResultExecution timeMemory
416677Dilshod_ImomovStations (IOI20_stations)C++17
0 / 100
969 ms55452 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 1e3 + 7; void dfs( vector<vector<int>> adj, int v, int p, int h, vector<int> &lb, int &cnt ) { for ( auto u: adj[v] ) { if ( u != p ) { dfs( adj, u, v, h + 1, lb, cnt ); } } lb[v] = cnt++; } vector<int> label(int n, int k, vector<int> U, vector<int> V) { vector < vector < int > > adj(n + 1); for ( int i = 0; i < n - 1; i++ ) { int u = U[i], v = V[i]; adj[u].push_back(v); adj[v].push_back(u); } vector < int > lb(n); int cnt = 0; dfs( adj, 0, -1, 0, lb, cnt ); return lb; } int find_next_station(int s, int t, vector<int> c) { int pr = -1; if ( c.back() > s ) { pr = c.back(); c.pop_back(); } // cout << tins << ' ' << touts << ' ' << pr << endl; for ( auto u: c ) { if ( t <= u) { return u; } } assert( pr != -1 ); return pr; }
#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...