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>
#define int32_t int
#define int64_t long long
const int32_t MAX_N = 1000;
struct Vertex {
int32_t inTime, outTime;
std::vector< int32_t > v;
};
Vertex g[MAX_N + 5];
void dfs(int32_t u, int32_t &t, int32_t par) {
g[u].inTime = t;
for(auto &v : g[u].v) {
if(v != par) {
t++;
dfs(v, t, u);
}
}
g[u].outTime = t;
}
std::vector< int32_t > label(int32_t n, int32_t k, std::vector< int32_t > u, std::vector< int32_t > v) {
for(int32_t i = 0; i < n; i++) {
g[i].v.clear();
}
for(int32_t i = 0; i < n - 1; i++) {
g[u[i]].v.push_back(v[i]);
g[v[i]].v.push_back(u[i]);
}
int32_t t = 0;
dfs(0, t, -1);
std::vector< int32_t > labels(n);
for(int32_t i = 0; i < n; i++) {
labels[i] = 1000 * g[i].inTime + g[i].outTime;
}
return labels;
}
int32_t find_next_station(int32_t s, int32_t t, std::vector< int32_t > c) {
int32_t lS = s / 1000;
int32_t rS = s % 1000;
int32_t lT = t / 1000;
int32_t rT = t / 1000;
if(lS <= lT && rS >= rT) {
for(auto &x : c) {
int32_t lX = x / 1000;
int32_t rX = x % 1000;
if(lX < lS) {
continue;
}
if(lX <= lT && rX >= rT) {
return x;
}
}
}
else {
for(auto &x : c) {
int32_t lX = x / 1000;
if(lX < lS) {
return x;
}
}
}
}
Compilation message (stderr)
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:81:1: warning: control reaches end of non-void function [-Wreturn-type]
81 | }
| ^
# | 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... |