#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 = 2005;
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 < 1500; 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 {
int par = (s - 1) / 2;
assert(binary_search(all(c), par));
return par;
}
assert(false);
return -1;
}
/*
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
518 ms |
772 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
544 ms |
716 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
576 ms |
780 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
980 ms |
784 KB |
Output is correct |
2 |
Incorrect |
745 ms |
712 KB |
Wrong query response. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
539 ms |
800 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |