Submission #416580

#TimeUsernameProblemLanguageResultExecution timeMemory
416580Dilshod_ImomovStations (IOI20_stations)C++17
10 / 100
867 ms55552 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, vector<int> &lb, int &cnt ) { lb[v] = cnt++; for ( auto u: adj[v] ) { if ( u != p ) { dfs( adj, u, v, lb, cnt ); } } lb[v] *= 1000; if ( cnt == 1000000 ) { 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, lb, cnt ); return lb; } int find_next_station(int s, int t, vector<int> c) { int tins = s / 1000, touts = s % 1000; int tint = t / 1000, toutt = t % 1000; int pr = -1; for ( auto u: c ) { int tinu = u / 1000, toutu = u % 1000; if ( tinu <= tins && toutu >= touts ) { pr = u; continue; } if ( tinu <= tint && toutu >= toutt ) { 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...