#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
const int Nmax=1010;
int N, K, Size[Nmax], Dep[Nmax];
vector<int> adj[Nmax], L;
void DFS_Size(int curr, int prev) {
Size[curr]=1;
for(int next:adj[curr]) if(next!=prev) {
Dep[next]=Dep[curr]+1;
DFS_Size(next, curr);
Size[curr]+=Size[next];
}
}
void DFS_Label(int curr, int prev, int s, int e) {
if(Dep[curr]%2) L[curr]=s++;
else L[curr]=e--;
for(int next:adj[curr]) if(next!=prev) {
DFS_Label(next, curr, s, s+Size[next]-1);
s+=Size[next];
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
N=n, K=k;
for(int i=0; i<N-1; i++) {
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
DFS_Size(0, -1);
L.resize(N);
DFS_Label(0, -1, 0, N-1);
return L;
}
int find_next_station(int s, int t, vector<int> c) {
for(int i:c) if(i==t) return i;
if(c[0]<s) {
if(s<t && t<c[c.size()-2]) return (*lower_bound(c.begin(), c.end(), t));
else return c.back();
}
else {
if(t<c[0] || t>s) return c[0];
else return (*(lower_bound(c.begin(), c.end(), t)-1));
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1393 ms |
2097156 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3070 ms |
308 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1096 ms |
2097156 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
304 KB |
Invalid labels (duplicates values). scenario=1, label=1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1716 ms |
2097156 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |