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"
#include "stations.h"
#include <vector>
using namespace std;
#define ll int
const ll N = 1000;
ll t = 0;
vector<ll> adj[N], lb(N, -1);
void dfs(ll s){
if(lb[s]>=0) return;
lb[s] = t++;
for(auto u : adj[s])
dfs(u);
lb[s] += 2*N*(t++);
}
vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
for(ll i=0; i<n-1; ++i){
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
dfs(0);
vector<int> r(n);
for(ll i=0; i<n; ++i) r[i] = lb[i];
return r;
}
int find_next_station(int s, int t, std::vector<int> c) {
ll x1 = s%(2*N); ll y1 = s/(2*N);
ll x2 = t%(2*N); ll y2 = t/(2*N);
//tempi di entrata e uscita dei target
if(x1 > y2 || y1 < x2){
for(auto u : c){
ll x3 = u%(2*N); ll y3 = u/(2*N);
if(x3 < x1 && y1 < y3) return u;
}
}
for(auto u : c){
ll x3 = u%(2*N); ll y3 = u/(2*N);
if(x3 <= x2 && y2 <= y3) return u;
}
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... |