#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();
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
clean();
set <int> id;
for (int i = 0; i < n; i++) {
id.insert(i);
}
vector <int> cnt(n, 0);
int center = 0;
for (int i = 0; i <= n - 2; i++) {
int x = u[i];
int y = v[i];
cnt[x]++;
cnt[y]++;
if (cnt[x] >= 2) {
center = x;
}
if (cnt[y] >= 2) {
center = y;
}
}
vector <int> labels(n);
for (int i = 0; i < n; i++) {
if (center == i) {
labels[i] = 0;
id.erase(0);
} else {
auto it = --id.end();
labels[i] = *it;
id.erase(it);
}
}
return labels;
}
int find_next_station(int s, int t, vector<int> c) {
if (binary_search(all(c), t)) {
return t;
} else {
return 0;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
577 ms |
708 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
464 ms |
656 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
546 ms |
784 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
878 ms |
712 KB |
Output is correct |
2 |
Correct |
665 ms |
656 KB |
Output is correct |
3 |
Incorrect |
587 ms |
708 KB |
Wrong query response. |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
536 ms |
712 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |