#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> edges[1005];
int a[1005];
vector<bool> used;
int timer=0;
void dfs(int u, int d){
if(d==0)a[u] = timer,timer++;
used[u] = true;
for(auto v:edges[u]){
if(used[v])continue;
dfs(v,d^1);
}if(d==1)a[u] = timer,timer++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
for(int i=0;i<n;i++)edges[i].clear();
for(int i=0;i<n-1;i++){
edges[u[i]].push_back(v[i]);
edges[v[i]].push_back(u[i]);
}
timer=0;
used.assign(n,0);
dfs(0,0);
vector<int> ans(n);
for(int i=0;i<n;i++)ans[i] = a[i];
return ans;
}
/*
1
5 10
0 1
1 2
2 3
3 4
3
1 3 121
1 4 121
0 1 122
*/
int find_next_station(int s, int t, vector<int> c) {
if(c[c.size()-1] < s){
int ans = c[0];
for(auto x : c){
if(min(s, x) <= t && t <= max(s, x))return x;
}return ans;
}else {
for(auto x : c)if(min(s, x) <= t && t <= max(s, x))return x;
return c[c.size()-1];
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
669 ms |
1108 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
487 ms |
852 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
549 ms |
992 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
951 ms |
948 KB |
Output is correct |
2 |
Incorrect |
893 ms |
992 KB |
Wrong query response. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
600 ms |
876 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |