#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(0, -1, 1);
vector<int> labels(n);
for (int i = 0; i < n; i++)
labels[i] = st[i];
// cerr << "edges {\n";
// for(int i = 0; i < n - 1; i++)
// cerr << u[i] << " -> " << v[i] << '\n';
// cerr << "}\n";
// for(int i = 0; i < n; i++)
// cerr << i << " : " << labels[i] << '\n';
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 |
618 ms |
784 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
500 ms |
712 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
557 ms |
784 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1099 ms |
656 KB |
Output is correct |
2 |
Correct |
806 ms |
852 KB |
Output is correct |
3 |
Incorrect |
768 ms |
656 KB |
Wrong query response. |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
645 ms |
792 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |