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;
#define ll long long
#define pb push_back
#define SZ(x) (int)(x).size()
#define all(x) begin(x), end(x)
const int n0 = 1003;
int T, d[n0];
vector <int> g[n0], ind;
void dfs(int v, int p) {
if (!d[v]) ind[v] = T++;
for (int to : g[v]) {
if (to == p) continue;
d[to] = d[v] ^ 1;
dfs(to, v);
}
if (d[v]) ind[v] = T++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
T = 0, memset(& d, 0, sizeof(d));
ind = vector <int>(n, 0);
for (int i = 0; i < n; i++) g[i].clear();
for (int i = 0; i < SZ(u); i++)
g[u[i]].pb(v[i]), g[v[i]].pb(u[i]);
dfs(0, 0);
//cerr << "ind\n";
//for (int i = 0; i < n; i++) cerr << ind[i] << ' ';
//cerr << '\n';
return ind;
}
int find_next_station(int s, int t, vector<int> c) {
//cerr << "s t " << s << ' ' << t << '\n';
//cerr << "c\n";
//for (int i : c) cerr << i << ' ';
//cerr << '\n';
if (c[0] > s) {
int last = s + 1;
for (int i = 0; i < SZ(c) - 1; i++) {
if (t >= last && t <= c[i]) {
//cerr << "ans " << c[i] << '\n';
return c[i];
}
last = c[i] + 1;
}
//cerr << "ans " << c.back() << '\n';
return c.back();
} else {
int last = s - 1;
for (int i = SZ(c) - 1; i > 0; i--) {
if (t >= c[i] && t <= last) {
//cerr << "ans " << c[i] << '\n';
return c[i];
}
last = c[i] - 1;
}
//cerr << "ans " << c.back() << '\n';
return c[0];
}
}
# | 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... |