#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vll vector<ll>
#define vi vector<int>
#define vvi vector<vi>
#define pi pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
#define fori(i,n) for(int i = 0; i < int(n); ++i)
vi label(int n, int k, vi u, vi v) {
vvi e(n);
fori(i,n-1){
e[u[i]].push_back(v[i]);
e[v[i]].push_back(u[i]);
}
int cur_label = 0;
vi res(n, -1);
auto dfs = [&](auto& self, int i, int parent) -> void {
res[i] = cur_label++;
for(int j : e[i]) {
if(j==parent) continue;
self(self, j, i);
}
};
dfs(dfs, 0, -1);
return res;
}
int find_next_station(int s, int t, vi c) {
sort(all(c));
if(t < s) return c[0]; // parent;
int i = 1;
while(i < c.size() && c[i] >= t) i++;
return c[i-1];
}
Compilation message
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:37:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
37 | while(i < c.size() && c[i] >= t) i++;
| ~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
579 ms |
608 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
449 ms |
528 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
638 ms |
484 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1105 ms |
400 KB |
Output is correct |
2 |
Incorrect |
842 ms |
400 KB |
Wrong query response. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
663 ms |
528 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |