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;
struct Node{
vector<int> to;
}point[1005];
vector<int> labels;
int num;
void build(int now,int last,int p){
if(p%2==0)labels[now]=num++;
for(int i=0;i<point[now].to.size();i++){
int next=point[now].to[i];
if(next!=last)build(next,now,p+1);
}
if(p%2==1)labels[now]=num++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
num=0;labels.clear();labels.resize(n);
for(int i=0;i<n;i++){point[i].to.clear();}
for(int i=0;i<n-1;i++){
point[u[i]].to.push_back(v[i]);
point[v[i]].to.push_back(u[i]);
}
build(0,-1,0);
//for(int i=0;i<n;i++)cout<<i<<":"<<labels[i]<<" ";cout<<endl;
return labels;
}
int find_next_station(int s, int t, vector<int> c){
if(c.size()==1)return c[0];
if(s>c[0]){
if(t<=c[0] || t>s)return c[0];
else return *--upper_bound(c.begin(),c.end(),t);
}
else{
if(t<s || t>=c.back())return c.back();
else return *lower_bound(c.begin(),c.end(),t);
}
}
Compilation message (stderr)
stations.cpp: In function 'void build(int, int, int)':
stations.cpp:16:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
16 | for(int i=0;i<point[now].to.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... |