#ifndef EVAL
#include "stub.cpp"
#endif
#include "stations.h"
#include <bits/stdc++.h>
#define fr first
#define sc second
#define pii pair<int, int>
#define pb push_back
#define szof(s) (int)s.size()
#define all(s) s.begin(), s.end()
using namespace std;
const int MAXN = 1005;
vector <int> G[MAXN]; // binary tree
vector <int> g[MAXN]; // cur component
void clean() {
for (int i = 0; i < MAXN; i++) {
g[i].clear();
}
}
bool was_build = false;
int tin[MAXN], tout[MAXN], tiktak = 0;
int pr[MAXN];
void precalc(int v, int par) {
pr[v] = par;
tin[v] = ++tiktak;
for (int to : G[v]) {
if (to != par) {
precalc(to, v);
}
}
tout[v] = tiktak;
}
bool father(int a, int b) {
return tin[a] <= tin[b] && tout[b] <= tout[a];
}
void build() {
for (int i = 0; i < 1000; i++) {
G[i + 1].pb(i / 2);
G[i / 2].pb(i + 1);
}
precalc(0, -1);
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
if (!was_build) {
build();
was_build = 1;
}
vector <int> labels(n);
for (int i = 0; i < n; i++) {
labels[i] = i;
}
return labels;
}
int find_next_station(int s, int t, vector<int> c) {
// check s father t
if (father(s, t)) {
for (int el : c) {
if (father(s, el) && father(el, t)) {
return el;
}
}
} else {
return (s - 1) / 2;
}
}
Compilation message
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:78:1: warning: control reaches end of non-void function [-Wreturn-type]
78 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
541 ms |
668 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
437 ms |
660 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
543 ms |
660 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
912 ms |
776 KB |
Output is correct |
2 |
Incorrect |
684 ms |
668 KB |
Wrong query response. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
538 ms |
664 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |