#include "stations.h"
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
const int N = 2020;
vector<int> G[N];
int T = 0;
int st[N];
void DFS(int u, int p, int d){
if(d)
st[u] = T ++;
for(auto adj : G[u])
if(adj != p)
DFS(adj, u, d ^ 1);
if(!d)
st[u] = T ++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
T = 0;
for(int i = 0; i < n; i++) G[i].clear();
for(int i = 0; i < n - 1; i++)
G[u[i]].pb(v[i]), G[v[i]].pb(u[i]);
DFS(1, -1, 1);
vector<int> labels(n);
for (int i = 0; i < n; i++)
labels[i] = st[i];
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
int sz = c.size();
if(s == 0){
sort(all(c));
for(auto x : c)
if(t <= x)
return x;
return c[0];
}
if(s < c[0]){
sort(all(c));
int dad = c.back();
if(t < s) return c.back();
for(int i = 0; i < sz - 1; i++){
if(t <= c[i])
return c[i];
}
return dad;
} else {
sort(all(c));
int dad = c[0];
if(t > s) return c.back();
for(int i = sz - 1; i > 0; i--){
if(t >= c[i])
return c[i];
}
return dad;
}
return c[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
785 ms |
784 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
679 ms |
740 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
856 ms |
776 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1329 ms |
656 KB |
Output is correct |
2 |
Correct |
761 ms |
728 KB |
Output is correct |
3 |
Incorrect |
997 ms |
664 KB |
Wrong query response. |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
708 ms |
796 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |