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) {
tin.resize(n);
tout.resize(n);
for(int i = 0;i<n;i++) {
g[u[i]].pb(v[i]);
g[v[i]].pb(u[i]);
}
dfs(0, 0);
vector<int> l(n);
for(int i = 0;i<n;i++) {
l[i]=(2*1000-1)*tin[i]+tout[i];
}
return l;
}
int find_next_station(int s, int t, std::vector<int> c) {
if((s%(2000-1)) >= t%(2000-1) and s/(2000-1) <= t/(2000-1)) {
for(int i=0;i<(int)c.size();i++) {
if((c[i]%(2000-1)) >= t%(2000-1) and c[i]/(2000-1) <= t/(2000-1))return c[i];
}
}
else {
for(int i = 0;i<(int)c.size();i++) {
if(s%(2000-1) <= c[i]%(2000-1) and s/(2000-1) >= c[i]/(2000-1)) {
return c[i];
}
}
}
return 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... |