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 nax = 1000;
vector<int>g[nax];
vector<int> labels;
int _tm;
void dfs(int v, int p = -1) {
labels[v] = _tm++;
for(int u : g[v]) if(u!=p) {
dfs(u, v);
}
labels[v] |= (_tm-1)<<10;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
labels.resize(n);
for(int i=0; i<n; ++i) g[i].clear();
for(int i=0; i<n-1; ++i) {
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
_tm = 1;
dfs(0);
return labels;
}
int find_next_station(int s, int t, vector<int> c) {
int m = c.size();
vector<pair<int,int>>rng(m);
for(int i=0; i<m; ++i) {
rng[i].first = (((1<<10)-1)&c[i]);
rng[i].second = (c[i] - rng[i].first) >> 10;
}
sort(rng.begin(), rng.end());
for(int i=1; i<m; ++i) {
if(t >= rng[i].first && t <= rng[i].second) {
return rng[i].first + (rng[i].second << 10);
}
}
return rng[0].first + (rng[0].second << 10);
}
# | 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... |