#include "stations.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define rmin(r, x) r = min(r, x)
#define rmax(r, x) r = max(r, x)
#define ends ' '
#define endl '\n'
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int maxn = 1e3 + 10;
int T;
vector<int> l, adj[maxn];
void dfs(int u, int p, bool f) {
if(f) l[u] = T++;
for(auto& v : adj[u]) if(v != p) dfs(v, u, f ^ true);
if(!f) l[u] = T++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
T = 0;
l.resize(n);
for(int i = 0; i < n; ++i) adj[i].clear();
for(int i = 0; i < u.size(); ++i) {
adj[u[i]].eb(v[i]);
adj[v[i]].eb(u[i]);
}
dfs(0, -1, true);
return l;
}
int find_next_station(int s, int t, vector<int> c) {
int n = c.size();
if(n == 1) return c[0];
if(s < c[0]) {
if(!s && (t < s || c[n - 2] < t)) return c[n - 1];
for(int i = 0; i < n; ++i) if(t <= c[i]) return c[i];
}
else {
if(t < c[1] || s < t) return c[0];
for(int i = n - 1; i >= 0; --i) if(c[i] <= t) return c[i];
}
}
Compilation message
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:32:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for(int i = 0; i < u.size(); ++i) {
| ~~^~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:51:1: warning: control reaches end of non-void function [-Wreturn-type]
51 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
650 ms |
1024 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
538 ms |
808 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
615 ms |
1024 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
901 ms |
768 KB |
Output is correct |
2 |
Correct |
734 ms |
876 KB |
Output is correct |
3 |
Incorrect |
646 ms |
1024 KB |
Wrong query response. |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
534 ms |
1008 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |