#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){
a[u] = timer;timer++;
used[u] = true;
for(auto v:edges[u]){
if(used[v])continue;
dfs(v);
}
}
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);
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) {
sort(c.begin(), c.end());
// cout << s << ": " << t << '\n';
if(t < s){
return c[0];
}else {
int ans = 0;
for(auto x : c){
if(x <= t)ans = max(ans, x);
// cout << x << ' ';
}//cout << '\n';
return ans;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
574 ms |
1104 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
450 ms |
736 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
600 ms |
872 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1089 ms |
816 KB |
Output is correct |
2 |
Correct |
680 ms |
908 KB |
Output is correct |
3 |
Incorrect |
601 ms |
1096 KB |
Wrong query response. |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
553 ms |
992 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |