Submission #1024319

#TimeUsernameProblemLanguageResultExecution timeMemory
1024319Ahmed_SolymanStations (IOI20_stations)C++14
0 / 100
2024 ms2097152 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector<vector<int>>adj; int mark=0; vector<int>l,r; void dfs(int node,int par){ l[node]=mark++; for(auto i:adj[node]){ if(i!=par)dfs(i,node); } r[node]=mark-1; } vector<int> label(int n, int k, vector<int> u, vector<int> v){ mark=0; adj.resize(n+5); l.resize(n+5); r.resize(n+5); for(int i=0;i<n-1;i++){ adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } dfs(0,0); vector<int>ret(n); for(int i=0;i<n;i++)ret[i]=l[i]*1000+r[i]; return ret; } bool is_anc(int u,int v){ v=v/1000; int in=u/1000,out=u%1000; if(v>=in && v<out)return 1; return 0; } int find_next_station(int s, int t,vector<int> c){ int p=0; for(auto i:c){ if(is_anc(i,s)){ p=i;continue; } if(is_anc(i,t)){ return t; } } return p; }
#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...