#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];
void clean() {
for (int i = 0; i < MAXN; i++) {
g[i].clear();
}
}
int tin[MAXN], tout[MAXN], tiktak = 0;
int pr[MAXN];
void precalc(int v, int par) {
tin[v] = ++tiktak;
pr[v] = par;
for (int to : g[v]) {
if (to != par) {
precalc(to, v);
}
}
tout[v] = tiktak;
}
void up(int v, vector <int> &vec) {
vec.pb(v);
if (pr[v] != -1) {
up(v, vec);
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
clean(); // на всякий случай
for (int i = 0; i <= n - 2; i++) {
int x = u[i];
int y = v[i];
g[x].pb(y);
g[y].pb(x);
}
precalc(0, -1);
vector <int> labels(n);
for (int i = 0; i < n; i++) {
vector <int> vec;
up(i, vec);
int mask = 0;
for (int el : vec) {
mask += (1 << el);
}
labels[i] = mask;
}
return labels;
}
bool father(int a, int b) {
return ((a & b) == a);
}
int find_next_station(int s, int t, vector<int> c) {
if (father(s, t)) {
for (int el : c) {
if (father(s, el) && father(el, t)) {
return el;
}
}
}
for (int el : c) {
if (father(el, s)) {
return el;
}
}
}
Compilation message
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:86:1: warning: control reaches end of non-void function [-Wreturn-type]
86 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1536 ms |
2097156 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1355 ms |
2097156 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1399 ms |
2097156 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1455 ms |
2097156 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1393 ms |
2097156 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |