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;
//#define int long long
#define pi pair<int, int>
#define pii pair<int, pi>
#define fi first
#define se second
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
vector<int> adj[1005];
vector<int> ans;
int cnt = 0;
int S[1005], E[1005];
void dfs(int x, int p){
S[x] = cnt++;
for(auto i : adj[x])if(i != p)dfs(i, x);
E[x] = cnt - 1;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
for(int i=0;i<n;i++)adj[i].clear();
for(int i=0;i<n-1;i++){
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
cnt = 0;
dfs(0, -1);
ans.resize(n);
for(int i=0;i<n;i++)ans[i] = S[i] * 1000 + E[i] - S[i];
return ans;
}
int find_next_station(int s, int t, std::vector<int> c) {
int st = s/1000, en = s % 1000;
en += st;
int st2 = t / 1000, en2 = t % 1000;
en2 += st2;
int lab = 0;
for(auto i : c){
int tmp = i / 1000, tmp2 = i % 1000;
tmp2 += tmp;
if(tmp <= st2 && tmp2 >= en2 && tmp >= st)return i;
if(tmp < st)lab = i;
}
return lab;
}
# | 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... |