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 <vector>
#include <iostream>
using namespace std;
#define ll long long
#define add push_back
#define len(a) ((int)(a).size())
vector<int> g[1005];
vector<int> labels;
int timer = -2;
void dfs(int v, int p, bool m){
if(m == 0) labels[v] = (timer += 2);
for(int i = 0; i < len(g[v]); i++){
int to = g[v][i];
if(to == p) continue;
dfs(to, v, !m);
}
if(m == 1) labels[v] = (timer += 2) + 1;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
labels.resize(n);
timer = -2;
for(int i = 0; i < n; i++) {
g[i].clear();
}
for(int i = 0; i < len(u); i++){
g[u[i]].add(v[i]);
g[v[i]].add(u[i]);
}
dfs(0, 0, false);
// for(int i = 0; i < n; i++){
// cout << labels[i] << " ";
// }
// cout << endl;
return labels;
}
int find_next_station(int s, int t, vector<int> c) {
if(len(c) == 1){
return c[0];
}
int l, r;
if(s % 2 == 0){
l = s;
r = (s == 0 ? c[len(c) - 1] : c[len(c) - 2]);
if(!(l <= t && t <= r)){
return c[len(c) - 1];
}
int ind = 0;
while(ind < len(c) && t <= c[ind]){ ind++; }
return c[--ind];
}
r = s;
l = c[1];
if(!(l <= t && t <= r)){
return c[0];
}
int ind = len(c) - 1;
while(ind >= 0 && t >= c[ind]) { ind--; }
return c[++ind];
}
# | 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... |