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 "stations.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
const int N = 1010;
typedef long long ll;
vector<int> g[N];
vector<int> tin, tout;
int cnt=0;
void dfs(int at, int p) {
tin[at]=++cnt;
for(int to:g[at]) {
if(to != p)dfs(to, at);
}
tout[at]=++cnt;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
cnt=0;
tin.clear();
tout.clear();
tin.resize(n);
tout.resize(n);
for(int i = 0;i<n-1;i++) {
g[u[i]].pb(v[i]);
g[v[i]].pb(u[i]);
}
dfs(0, 0);
for(int i = 0;i<n;i++) {
tin[i]--;
tout[i]--;
}
vector<int> l(n);
for(int i = 0;i<n;i++) {
l[i]=(2*1001-1)*tin[i]+tout[i];
}
for(int i = 0;i<=n;i++)g[i].clear();
return l;
}
int find_next_station(int s, int t, std::vector<int> c) {
int k =0;
for(int i=0;i<(int)c.size();i++) {
if(s%(2001-1) <= c[i]%(2001-1) and s/(2001-1) >= c[i]/(2001-1)){
k=c[i];
continue;
}
if((c[i]%(2001-1)) >= t%(2001-1) and c[i]/(2001-1) <= t/(2001-1))return c[i];
}
return k;
}
# | 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... |