#include <bits/stdc++.h>
using namespace std;
#include "stations.h"
#include <vector>
const int N = 1001;
vector<int> adj[N];
vector<int> order;
void dfs(int i, int p) {
order.push_back(i);
for (int c: adj[i]) {
if (c == p) continue;
dfs(c,i);
}
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
order.clear();
for (int i=0; i<n; i++) adj[i].clear();
std::vector<int> labels(n);
for (int i=0; i<n-1; i++) {
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
for (int i=0; i<n; i++) {
if (adj[i].size()==1) {
dfs(i,i); break;
}
}
for (int i=0; i<n; i++) {
labels[order[i]] = i;
}
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
if (s<t) return s+1;
return s-1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
360 ms |
684 KB |
Output is correct |
2 |
Correct |
340 ms |
684 KB |
Output is correct |
3 |
Correct |
632 ms |
684 KB |
Output is correct |
4 |
Correct |
405 ms |
684 KB |
Output is correct |
5 |
Correct |
366 ms |
684 KB |
Output is correct |
6 |
Correct |
285 ms |
684 KB |
Output is correct |
7 |
Correct |
292 ms |
688 KB |
Output is correct |
8 |
Correct |
2 ms |
772 KB |
Output is correct |
9 |
Correct |
1 ms |
776 KB |
Output is correct |
10 |
Correct |
1 ms |
768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
306 ms |
688 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
341 ms |
684 KB |
Output is correct |
2 |
Correct |
321 ms |
684 KB |
Output is correct |
3 |
Correct |
615 ms |
684 KB |
Output is correct |
4 |
Correct |
468 ms |
684 KB |
Output is correct |
5 |
Correct |
368 ms |
948 KB |
Output is correct |
6 |
Correct |
245 ms |
684 KB |
Output is correct |
7 |
Correct |
276 ms |
796 KB |
Output is correct |
8 |
Correct |
1 ms |
768 KB |
Output is correct |
9 |
Correct |
1 ms |
768 KB |
Output is correct |
10 |
Correct |
1 ms |
776 KB |
Output is correct |
11 |
Incorrect |
368 ms |
940 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
635 ms |
684 KB |
Output is correct |
2 |
Correct |
446 ms |
684 KB |
Output is correct |
3 |
Correct |
368 ms |
684 KB |
Output is correct |
4 |
Correct |
2 ms |
768 KB |
Output is correct |
5 |
Correct |
2 ms |
768 KB |
Output is correct |
6 |
Correct |
0 ms |
776 KB |
Output is correct |
7 |
Incorrect |
414 ms |
684 KB |
Wrong query response. |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
368 ms |
684 KB |
Output is correct |
2 |
Correct |
299 ms |
684 KB |
Output is correct |
3 |
Correct |
583 ms |
688 KB |
Output is correct |
4 |
Correct |
421 ms |
684 KB |
Output is correct |
5 |
Correct |
365 ms |
684 KB |
Output is correct |
6 |
Correct |
288 ms |
944 KB |
Output is correct |
7 |
Correct |
278 ms |
684 KB |
Output is correct |
8 |
Correct |
1 ms |
768 KB |
Output is correct |
9 |
Correct |
1 ms |
772 KB |
Output is correct |
10 |
Correct |
1 ms |
768 KB |
Output is correct |
11 |
Incorrect |
326 ms |
684 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |