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;
using ll = int;
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
vector<ll> labels(n);
iota(labels.begin(),labels.end(),0);
vector<vector<ll>> con(n);
for(ll i = 0;i<n-1;i++){
con[u[i]].push_back(v[i]);
con[v[i]].push_back(u[i]);
}
fill(labels.begin(),labels.end(),-1);
for(ll i = 0;i<n;i++){
if (con[i].size()==1&&labels[i]==-1){
ll cur = i;
ll it = 0;
while(cur!=-1){
labels[cur] = it++;
ll nxt = -1;
for(ll j : con[cur]) if (labels[j]==-1) nxt = j;
cur = nxt;
}
}
}
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
/*s++;t++;
ll lgs = __lg(s), lgt = __lg(t);
if (lgs<lgt){
ll x = t>>(lgt-lgs);
if (s==x){
return (t>>(lgt-lgs-1))-1;
}
}
return (s>>1)-1;*/
if (t>s) return s+1;
else return s-1;
}
# | 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... |