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 <bits/stdc++.h>
using namespace std;
const int Mx = 1010;
int timer = 0;
int tin[Mx],tout[Mx];
void dfs(int node,int par,vector<int> &labels,vector<vector<int>> &tr,bool parity){
tin[node] = timer++;
for(auto i:tr[node]){
if(i != par){
dfs(i,node,labels,tr,!parity);
}
}
tout[node] = timer++;
labels[node] = (parity ? tin[node] : tout[node]);
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
vector<int> labels(n);
vector<vector<int>> tr(n+1,vector<int>(0));
for (int i = 0; i < n-1; i++) {
tr[u[i]].push_back(v[i]);
tr[v[i]].push_back(u[i]);
}
dfs(0,-1,labels,tr,1);
for(int i=0;i<n;i++){
labels[i]/=2;
}
return labels;
}
int find_next_station(int s, int t, vector<int> c) {
if ((int)c.size() == 1) return c.back();
if (c.front() > s){
// s in tin
int l = s, r = c[(int)c.size() - 2];
if (l > t || r < t) return c.back();
int pos = lower_bound(c.begin(), c.end(), t) - c.begin();
return c[pos];
}
// s is tout
int l = c[1], r = s;
if (l > t || r < t) return c.front();
int pos = upper_bound(c.begin(), c.end(), t) - c.begin() - 1;
return c[pos];
}
# | 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... |