#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);
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.back();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
550 ms |
1024 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
496 ms |
804 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
598 ms |
776 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
927 ms |
880 KB |
Output is correct |
2 |
Incorrect |
678 ms |
768 KB |
Wrong query response. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
622 ms |
768 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |