#include <bits/stdc++.h>
using namespace std;
#include "stations.h"
const int N = 1001;
vector<int> adj[N];
int tin[N];
int tout[N];
vector<int> order;
void dfs(int i, int p, int tp) {
if (!tp) order.push_back(i);
else order.push_back(-1);
for (int c: adj[i]) {
if (c == p) continue;
dfs(c,i, !tp);
}
if (tp) order.push_back(i);
else order.push_back(-1);
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
order.clear(); for (int i=0; i<n; i++) adj[i].clear();
std::vector<int> labels(n);
for (int i=0; i<n-1; i++) {
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
dfs(0,0,0);
for (int i=0; i<2*n; i++) if (order[i]!=-1) labels[order[i]] = i;
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
if (s > c[0]) {
// s is time-out, all neighbors are time-in
// c[0] is the parent
int n = c.size();
vector<int> tout(n);
for (int i=1; i<n-1; i++) {
tout[i] = tin[i+1];
}
tout[n-1] = s;
for (int i=1; i<n; i++) {
if (c[i] <= t && t<=tout[i]) return c[i];
}
return c[0];
} else {
// s is time-in, all neighbors are time-out
// c[n-1] is the parent
int n = c.size();
vector<int> tin(n);
for (int i=n-2; i>0; i--) {
tin[i] = c[i-1];
}
tin[0] = s;
for (int i=0; i<n-1; i++) {
if (tin[i] <= t && t<=c[i]) return c[i];
}
return c[n-1];
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
600 KB |
Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=1990 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
532 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1022 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
359 ms |
800 KB |
Output is correct |
2 |
Correct |
294 ms |
932 KB |
Output is correct |
3 |
Correct |
600 ms |
684 KB |
Output is correct |
4 |
Correct |
442 ms |
684 KB |
Output is correct |
5 |
Correct |
447 ms |
684 KB |
Output is correct |
6 |
Correct |
285 ms |
940 KB |
Output is correct |
7 |
Correct |
287 ms |
684 KB |
Output is correct |
8 |
Correct |
1 ms |
776 KB |
Output is correct |
9 |
Correct |
3 ms |
776 KB |
Output is correct |
10 |
Correct |
0 ms |
768 KB |
Output is correct |
11 |
Incorrect |
445 ms |
684 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
564 ms |
688 KB |
Output is correct |
2 |
Correct |
474 ms |
684 KB |
Output is correct |
3 |
Correct |
414 ms |
684 KB |
Output is correct |
4 |
Correct |
1 ms |
764 KB |
Output is correct |
5 |
Correct |
1 ms |
764 KB |
Output is correct |
6 |
Correct |
0 ms |
772 KB |
Output is correct |
7 |
Incorrect |
401 ms |
684 KB |
Wrong query response. |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
380 ms |
940 KB |
Partially correct |
2 |
Partially correct |
306 ms |
932 KB |
Partially correct |
3 |
Correct |
634 ms |
688 KB |
Output is correct |
4 |
Correct |
467 ms |
684 KB |
Output is correct |
5 |
Correct |
385 ms |
684 KB |
Output is correct |
6 |
Partially correct |
303 ms |
936 KB |
Partially correct |
7 |
Partially correct |
302 ms |
684 KB |
Partially correct |
8 |
Correct |
1 ms |
768 KB |
Output is correct |
9 |
Correct |
3 ms |
768 KB |
Output is correct |
10 |
Correct |
1 ms |
776 KB |
Output is correct |
11 |
Incorrect |
303 ms |
684 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |