#include "stations.h"
#include <vector>
#include <algorithm>
using namespace std;
vector<int> adj[1000];
vector<int> labels;
int sub[1000];
void dfs1(int x, int p)
{
sub[x] = 1;
for(int i : adj[x])
{
if(i == p) continue;
dfs1(i, x);
sub[x] += sub[i];
}
}
void dfs2(int x, int p, int d, int l, int r){
if(d == 0) labels[x] = l;
else labels[x] = r;
int tmp = l;
if(d == 0) tmp++;
for(int i : adj[x])
{
if(i == p) continue;
dfs2(i, x, !d, tmp, tmp + sub[i] - 1);
tmp += sub[i];
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
labels.resize(n);
for(int i=0;i<n-1;i++){
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
dfs1(0, -1);
dfs2(0, -1, 0, 0, n-1);
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
int n = c.size() - 1;
int m = c[0], M = c[n];
if(m > s)
{
if(t < s) return M;
for(int i=0;i<=n;i++)
{
if(t < c[i]) return c[i];
}
return M;
}
if(t > s || t < m) return m;
for(int i=n;i>=0;i--)
{
if(t >= c[i]) return c[i];
}
return c[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1906 ms |
2097156 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3052 ms |
412 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1361 ms |
2097156 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1111 ms |
524 KB |
Output is correct |
2 |
Runtime error |
1085 ms |
2097156 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2173 ms |
2097156 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |