Submission #986573

#TimeUsernameProblemLanguageResultExecution timeMemory
986573CSQ31Stations (IOI20_stations)C++17
0 / 100
529 ms912 KiB
#include "stations.h" #include<bits/stdc++.h> using namespace std; vector<int>adj[1000]; int tin[1000],tout[1000]; int timer = 0; void dfs(int v,int u){ tin[v] = timer++; for(int x:adj[v]){ if(x==u)continue; dfs(x,v); } tout[v] = timer; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { for(int i=0;i<n;i++)adj[i].clear(); timer = 0; vector<int>lab(n); for(int i=0;i+1<n;i++){ adj[v[i]].push_back(u[i]); adj[u[i]].push_back(v[i]); } dfs(0,-1); for(int i=0;i<n;i++)lab[i] = 1000*tin[i] + tout[i]; return lab; } int find_next_station(int s, int t, vector<int> c) { int tl = t/1000; int tr = t%1000; int sl = s/1000; int sr = s%1000; bool out = 1; if(sl <= tl && tr <= sr)out = 0; for(int x:c){ int l = x/1000; int r = x%1000; if(l <= tl && tr <= r)return x; else if(out)return x; } return c[0]; }
#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...