#ifndef EVAL
#include "stub.cpp"
#endif
#include "stations.h"
#include <bits/stdc++.h>
#define fr first
#define sc second
#define pii pair<int, int>
#define pb push_back
#define szof(s) (int)s.size()
#define all(s) s.begin(), s.end()
using namespace std;
const int MAXN = 1005;
vector <int> g[MAXN];
void save(int v, int par, vector <int> &order) {
order.pb(v);
for (int to : g[v]) {
if (par != to) {
save(to, v, order);
}
}
}
void clean() {
for (int i = 0; i < MAXN; i++) {
g[i].clear();
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
clean();
for (int i = 0; i <= n - 2; i++) {
int x = u[i];
int y = v[i];
g[x].pb(y);
g[y].pb(x);
}
int root = -1;
for (int i = 0; i < n; i++) {
if (szof(g[i]) == 1) {
root = i;
break;
}
}
vector <int> order;
save(root, -1, order);
vector <int> labels(n);
for (int i = 0; i < n; i++) {
int cur = order[i];
labels[cur] = i;
}
return labels;
}
int find_next_station(int s, int t, vector<int> c) {
int left = min(s, t);
int right = max(s, t);
for (int el : c) {
if (left <= el && el <= right) {
return el;
}
}
assert(false);
return -1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
525 ms |
528 KB |
Output is correct |
2 |
Correct |
415 ms |
500 KB |
Output is correct |
3 |
Correct |
923 ms |
508 KB |
Output is correct |
4 |
Correct |
803 ms |
512 KB |
Output is correct |
5 |
Correct |
614 ms |
512 KB |
Output is correct |
6 |
Correct |
461 ms |
528 KB |
Output is correct |
7 |
Correct |
469 ms |
512 KB |
Output is correct |
8 |
Correct |
3 ms |
468 KB |
Output is correct |
9 |
Correct |
5 ms |
464 KB |
Output is correct |
10 |
Correct |
2 ms |
472 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
6 ms |
784 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
553 ms |
656 KB |
Output is correct |
2 |
Correct |
426 ms |
532 KB |
Output is correct |
3 |
Correct |
824 ms |
400 KB |
Output is correct |
4 |
Correct |
662 ms |
520 KB |
Output is correct |
5 |
Correct |
577 ms |
400 KB |
Output is correct |
6 |
Correct |
413 ms |
528 KB |
Output is correct |
7 |
Correct |
455 ms |
528 KB |
Output is correct |
8 |
Correct |
3 ms |
468 KB |
Output is correct |
9 |
Correct |
4 ms |
468 KB |
Output is correct |
10 |
Correct |
2 ms |
468 KB |
Output is correct |
11 |
Runtime error |
2 ms |
656 KB |
Execution killed with signal 6 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
857 ms |
400 KB |
Output is correct |
2 |
Correct |
615 ms |
512 KB |
Output is correct |
3 |
Correct |
593 ms |
528 KB |
Output is correct |
4 |
Correct |
2 ms |
540 KB |
Output is correct |
5 |
Correct |
4 ms |
468 KB |
Output is correct |
6 |
Correct |
2 ms |
464 KB |
Output is correct |
7 |
Runtime error |
2 ms |
656 KB |
Execution killed with signal 6 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
517 ms |
512 KB |
Output is correct |
2 |
Correct |
450 ms |
512 KB |
Output is correct |
3 |
Correct |
891 ms |
400 KB |
Output is correct |
4 |
Correct |
638 ms |
400 KB |
Output is correct |
5 |
Correct |
565 ms |
528 KB |
Output is correct |
6 |
Correct |
446 ms |
528 KB |
Output is correct |
7 |
Correct |
425 ms |
528 KB |
Output is correct |
8 |
Correct |
3 ms |
468 KB |
Output is correct |
9 |
Correct |
4 ms |
476 KB |
Output is correct |
10 |
Correct |
2 ms |
476 KB |
Output is correct |
11 |
Runtime error |
6 ms |
784 KB |
Execution killed with signal 6 |
12 |
Halted |
0 ms |
0 KB |
- |