#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define x first
#define y second
#define ld long double
#define ll long long
using namespace std;
vector <int> g[1005];
int nr;
void dfs(int nod, int h, int tata, vector <int> &labels) {
if(h % 2 == 0)
labels[nod] = nr++;
for(auto &fiu : g[nod]) {
if(fiu != tata)
dfs(fiu, h + 1, nod, labels);
}
if(h % 2)
labels[nod] = nr++;
}
vector <int> label(int n, int k, vector <int> u, vector <int> v) {
vector <int> labels;
for(int i = 0; i < n - 1; i++) {
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
labels.resize(n);
dfs(0, 0, -1, labels);
return labels;
}
int find_next_station(int s, int t, vector <int> c) {
if(s < c[0]) {
int tmp = s;
for(auto &i : c) {
if(tmp < t && t <= i)
return i;
tmp = i;
}
return c.back();
}
for(int i = 0; i < c.size(); i++) {
if(c[i] <= t && t < (i != c.size() - 1 ? c[i + 1] : s + 1))
return c[i];
}
return c[0];
}
Compilation message
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:45:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | for(int i = 0; i < c.size(); i++) {
| ~~^~~~~~~~~~
stations.cpp:46:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | if(c[i] <= t && t < (i != c.size() - 1 ? c[i + 1] : s + 1))
| ~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1399 ms |
2097156 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
768 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1378 ms |
2097156 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1006 ms |
876 KB |
Output is correct |
2 |
Runtime error |
1157 ms |
2097156 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2186 ms |
2097152 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |