#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
const int nx=1e3+5;
int st, cnt;
vector<int> d[nx], res;
void dfs(int u, int p)
{
//cout<<"dfs "<<u<<' '<<p<<'\n';
res[u]=cnt++;
for (auto v:d[u]) if (v!=p) dfs(v, u);
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
for (int i=0; i<n; i++) d[i].clear();
for (int i=0; i<n-1; i++) d[u[i]].push_back(v[i]), d[v[i]].push_back(u[i]);
for (int i=0; i<n; i++) if (d[i].size()==1) st=i;
res.resize(n);
cnt=0;
dfs(st, st);
//for (int i=0; i<n; i++) cout<<"debug "<<i<<' '<<res[i]<<'\n';
return res;
}
int find_next_station(int s, int t, std::vector<int> c) {
if (c.size()==1) return c[0];
if (t<s) return c[0];
else return c[1];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
368 ms |
1044 KB |
Output is correct |
2 |
Correct |
252 ms |
904 KB |
Output is correct |
3 |
Correct |
545 ms |
688 KB |
Output is correct |
4 |
Correct |
449 ms |
684 KB |
Output is correct |
5 |
Correct |
451 ms |
684 KB |
Output is correct |
6 |
Correct |
300 ms |
908 KB |
Output is correct |
7 |
Correct |
285 ms |
696 KB |
Output is correct |
8 |
Correct |
1 ms |
768 KB |
Output is correct |
9 |
Correct |
2 ms |
768 KB |
Output is correct |
10 |
Correct |
0 ms |
768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
270 ms |
872 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
369 ms |
1308 KB |
Output is correct |
2 |
Correct |
284 ms |
896 KB |
Output is correct |
3 |
Correct |
520 ms |
684 KB |
Output is correct |
4 |
Correct |
421 ms |
940 KB |
Output is correct |
5 |
Correct |
367 ms |
684 KB |
Output is correct |
6 |
Correct |
294 ms |
896 KB |
Output is correct |
7 |
Correct |
309 ms |
684 KB |
Output is correct |
8 |
Correct |
3 ms |
764 KB |
Output is correct |
9 |
Correct |
4 ms |
768 KB |
Output is correct |
10 |
Correct |
0 ms |
768 KB |
Output is correct |
11 |
Incorrect |
403 ms |
936 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
599 ms |
684 KB |
Output is correct |
2 |
Correct |
466 ms |
684 KB |
Output is correct |
3 |
Correct |
398 ms |
684 KB |
Output is correct |
4 |
Correct |
1 ms |
768 KB |
Output is correct |
5 |
Correct |
2 ms |
764 KB |
Output is correct |
6 |
Correct |
0 ms |
768 KB |
Output is correct |
7 |
Incorrect |
412 ms |
684 KB |
Wrong query response. |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
319 ms |
912 KB |
Output is correct |
2 |
Correct |
290 ms |
908 KB |
Output is correct |
3 |
Correct |
583 ms |
684 KB |
Output is correct |
4 |
Correct |
438 ms |
684 KB |
Output is correct |
5 |
Correct |
374 ms |
684 KB |
Output is correct |
6 |
Correct |
269 ms |
908 KB |
Output is correct |
7 |
Correct |
283 ms |
688 KB |
Output is correct |
8 |
Correct |
2 ms |
1016 KB |
Output is correct |
9 |
Correct |
3 ms |
1016 KB |
Output is correct |
10 |
Correct |
0 ms |
768 KB |
Output is correct |
11 |
Incorrect |
310 ms |
868 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |