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;
vector<int>adj[1010];
int CC;
void dfs(int n,vector<int>&cols,int dep=0,int p=-1){
if(dep)cols[n]=CC++;
for(auto i:adj[n])if(i-p)
dfs(i,cols,!dep,n);
if(!dep)cols[n]=CC++;
}
vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
CC=0;
for(int i=0;i<n;i++)
adj[i].clear();
vector<int>res(n);
for(int i=0;i<n-1;i++)
adj[u[i]].push_back(v[i]),
adj[v[i]].push_back(u[i]);
dfs(0,res);
return res;
}
int find_next_station(int s, int t, std::vector<int> c) {
if(s<c[0]){
if(t<s)
return c.back();
for(auto i:c)
if(t<=i)
return i;
return c.back();
} else {
if(t>s)
return c[0];
reverse(c.begin(),c.end());
int prv=s;
for(auto i:c)
if(t>=i)
return i;
return c.back();
}
}
Compilation message (stderr)
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:36:13: warning: unused variable 'prv' [-Wunused-variable]
36 | int prv=s;
| ^~~
# | 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... |