#include "stations.h"
#include <vector>
using namespace std;
vector<int> gph[1010];
int ord[1010];
int cnt = 0;
void dfs(int x, int p, bool flag)
{
if(flag) ord[x] = ++cnt;
for(auto y : gph[x]) if(y != p) dfs(y, x, !flag);
if(!flag) ord[x] = ++cnt;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v)
{
vector<int> labels(n);
for(int i = 0; i < n; ++i) ord[i] = 0;
cnt = 0;
for(int i = 0; i < n - 1; ++i)
{
gph[u[i]].push_back(v[i]);
gph[v[i]].push_back(u[i]);
}
dfs(0, 0, false);
for(int i = 0; i < n; ++i) labels[i] = ord[i];
return labels;
}
int find_next_station(int s, int t, vector<int> c)
{
int n = c.size();
if(s < c[0])
{
int pr = s;
for(int i = 0; i < n - 1; ++i)
{
if(pr < t && t <= c[i]) return c[i];
pr = c[i];
}
return c[n - 1];
}
else
{
int pr = s;
for(int i = n - 1; i >= 1; --i)
{
if(c[i] <= t && t < pr) return c[i];
pr = c[i];
}
return c[0];
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1429 ms |
2097156 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3056 ms |
504 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1434 ms |
2097156 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
970 ms |
884 KB |
Output is correct |
2 |
Runtime error |
1205 ms |
2097156 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2305 ms |
2097156 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |