#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e3+3;
vector<int> adj[MAXN];
int tin[MAXN], tout[MAXN], tempo;
void dfs(int no, int anc){
tin[no] = tempo++;
for(int v : adj[no]) if(v != anc){
dfs(v, no);
}
tout[no] = tempo;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
for (int i = 0; i < n; i++){
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
dfs(0, 0);
vector<int> labels(n);
for (int i = 0; i < n; i++) {
labels[i] = tin[i]*1000+tout[i];
}
return labels;
}
inline int _tin(int a){
return a/1000;
}
inline int _tout(int a){
return a%1000;
}
int find_next_station(int s, int t, vector<int> c) {
if(_tin(s) <= _tin(t) && _tout(t) <= _tout(s)){ //t eh filho
for(int l : c){
if(_tin(l) <= _tin(s) && _tout(s) <= _tout(l)) continue;
if(_tin(l) <= _tin(t) && _tout(t) <= _tout(l)){ //t eh meu filho
return l;
}
}
}
for(int l : c){
if(_tin(l) <= _tin(s) && _tout(s) <= _tout(l)) return l;
}
return c[0];
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |