Submission #601886

#TimeUsernameProblemLanguageResultExecution timeMemory
601886FatihSolakStations (IOI20_stations)C++17
10 / 100
830 ms628 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; #define N 1000 vector<int> adj[N]; int tin[N]; int tout[N]; int timer = 0; void dfs(int v,int par){ tin[v] = timer++; for(auto u:adj[v]){ if(u == par)continue; dfs(u,v); } tout[v] = timer-1; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { for(int i = 0;i<n;i++){ adj[i].clear(); } for(int i = 0;i<n-1;i++){ adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } dfs(0,-1); vector<int> labels(n); for (int i = 0; i < n; i++) { labels[i] = tin[i] * N + tout[i]; } return labels; } int find_next_station(int s, int t, vector<int> c) { int x = t / N; int par = -1; for(auto u:c){ if(u / N < s / N) par = u; } for(auto u:c){ if(u == par)continue; int a = u / N; int b = u % N; if(a <= x && x <= b) return u; } return par; }
#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...