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>
#define MEM 111111
#define sanic ios_base::sync_with_stdio(0)
#define x first
#define y second
#define sz size()
#define pb push_back
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
const ll INF = 1e13+7;
const ll MOD = 1e9+7;
vector<ll> g[MEM];
ll lb[MEM];
ll o;
void dfs(ll c, ll lv, ll p){
if(lv&1) lb[c] = o++;
for(ll nt:g[c]){
if(nt==p) continue;
dfs(nt, lv+1, c);
}
if(!(lv&1)) lb[c] = o++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
std::vector<int> labels(n);
for(int i=0; i<u.sz; i++){
g[u[i]].pb(v[i]);
g[v[i]].pb(u[i]);
}
memset(lb, 0, sizeof(lb));
o = 0;
dfs(0, 1, -1);
for(int i=0; i<n; i++)
labels[i] = lb[i];
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
if(c.back()<s) reverse(c.begin(), c.end());
for(int r : c)
if(min(s, r)<=t && t<=max(s, r)) return r;
return c.back();
}
Compilation message (stderr)
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:28:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | for(int i=0; i<u.sz; 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... |