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 <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int MAXN=1e3+10;
vector <int> ver[MAXN];
vector <int> in;
int br;
void dfs(int x, int par) {
in[x]=br;
br++;
for (auto i:ver[x]) {
if (i==par) continue;
dfs(i,x);
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
in.resize(n);
br=0;
for (int i=0;i<n-1;i++) {
ver[u[i]].push_back(v[i]);
ver[v[i]].push_back(u[i]);
}
dfs(0,-1);
return in;
}
int find_next_station(int s, int t, vector<int> c) {
if (s>t) return c[0];
int l, r, mid;
l=0; r=c.size()-1;
while (l<=r) {
mid=(l+r)/2;
if (c[mid]<=t) l=mid+1;
else r=mid-1;
}
return c[r];
}
# | 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... |