# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1024336 | Ahmed_Solyman | Stations (IOI20_stations) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#include "stations.h"
typedef long long ll;
vector<vector<int>>adj;
int mark=0;
vector<int>in,vis;
void dfs(int node,int par){
in[node]=mark++;vis[i]=1;
for(auto i:adj[node]){
if(i!=par)dfs(i,node);
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v){
mark=0;
adj.resize(n);
in.resize(n);vis.resize(n);
for(int i=0;i<n-1;i++){
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
for(int i=0;i<n;i++){
if(adj[i].size()==1){
dfs(i,i);break;
}
}
return in;
}
int find_next_station(int s, int t,vector<int> c){
int p=0;
for(auto i:c){
if(i<=s){
p=i;continue;
}
if(i<=t){
return i;
}
}
return p;
}