#include <bits/stdc++.h>
#include "stations.h"
using namespace std;
using ll = long long;
ll n, m, q, k, x, y, a, b, c;
vector<ll> G[10000];
void dfs(ll x, ll p, ll depth, ll &timer, vector<int> &ans) {
// cout << x << ' ' << p << ' ' << depth << ' ' << timer << endl;
if (depth % 2 == 0) {
ans[x] = timer;
}
timer++;
for (int i : G[x]) {
if (i != p) {
dfs(i, x, depth + 1, timer, ans);
}
}
if (depth % 2 == 1) {
ans[x] = timer;
}
timer++;
}
vector<int> label(int N, int K, vector<int> u, vector<int> v) {
n = N;
k = K;
for (int i = 0; i < n - 1; i++) {
G[u[i]].push_back(v[i]);
G[v[i]].push_back(u[i]);
}
vector<int> ans(n);
ll timer = 1;
dfs(0, -1, 0, timer, ans);
// for (int i = 0; i < n; i++) {
// cout << ans[i] << ' ';
// }
// cout << endl;
return ans;
}
int find_next_station(int s, int t, std::vector<int> c) {
if (s > c[c.size() - 1]) {
for (int i = 1; i < c.size(); i++) {
if (c[i] > t) {
return c[i - 1];
}
}
if (s > t) {
return c[c.size() - 1];
}
return c[0];
}
else {
if (s == 1) {
for (int i = 1; i < c.size(); i++) {
if (c[i] > t) {
return c[i - 1];
}
}
return c[c.size() - 1];
}
else {
if (s > t) {
return c[c.size() - 1];
}
for (int i = 1; i < c.size(); i++) {
if (c[i] > t) {
return c[i - 1];
}
}
return c[c.size() - 1];
}
}
}
Compilation message
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:46:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | for (int i = 1; i < c.size(); i++) {
| ~~^~~~~~~~~~
stations.cpp:58:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
58 | for (int i = 1; i < c.size(); i++) {
| ~~^~~~~~~~~~
stations.cpp:69:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
69 | for (int i = 1; i < c.size(); i++) {
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
1624 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
1180 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1337 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
571 ms |
1196 KB |
Output is correct |
2 |
Runtime error |
1059 ms |
2097152 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1708 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |