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> grafo[1003];
int arr[1003],C;
bool vis[1003];
void dfs(int node,int c){
vis[node]=true;
if(c) arr[node]=C++;
for(auto i:grafo[node]) if(!vis[i]) dfs(i,c^1);
if(!c) arr[node]=C++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
for(int i=0;i<n;i++) grafo[i].clear();
for(int i=0;i<n-1;i++) grafo[u[i]].push_back(v[i]),grafo[v[i]].push_back(u[i]);
fill(arr,arr+n+1,0);
fill(vis,vis+n+1,false);
C=0,dfs(0,0);
vector <int> solve;
for(int i=0;i<n;i++) solve.push_back(arr[i]);
return solve;
}
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(i>=t) return i;
}
for(int i=1;i<c.size();i++) if(c[i]<=t) return c[i];
return c[0];
}
Compilation message (stderr)
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:33:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for(int i=1;i<c.size();i++) if(c[i]<=t) return c[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... |