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>
#include "stations.h"
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
vector<int>label(int n,int k,vector<int>u,vector<int>v){
vector<int>l(n);
vector<int>adj[n];
for(int i=0;i<n-1;i++){
adj[u[i]].pb(v[i]);
adj[v[i]].pb(u[i]);
}
int mx=0;
for(int i=0;i<n;i++){
mx=max(mx,(int)adj[i].size());
}
if(mx<=2){
vector<int>ord;
function <void(int,int)> dfs=[&](int x,int p){
ord.pb(x);
for(auto y:adj[x]){
if(y!=p){
dfs(y,x);
}
}
};
for(int i=0;i<n;i++){
if(adj[i].size()==1){
dfs(i,-1);
break;
}
}
for(int i=0;i<n;i++){
l[ord[i]]=i;
}
return l;
}
iota(all(l),1000);
return l;
}
int find_next_station(int s,int t,vector<int>c){
if(s>=1000){
if(t<s) return c[0];
for(int i=1;i<c.size();i++){
int p=c[i]-1000,T=t-1000;
while(T>p){
T=(T-1)/2;
}
if(T==p){
return c[i];
}
}
return c[0];
}
else{
if(s>t) return c[0];
return c.back();
}
}
Compilation message (stderr)
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:52:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | for(int i=1;i<c.size();i++){
| ~^~~~~~~~~
# | 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... |