#include <bits/stdc++.h>
#include "stations.h"
using namespace std;
bool line = 1;
bool binary = 1;
const int N = 1001;
vector<vector<int>> go(N, vector<int>(N));
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
vector<vector<int>> adj(n);
for (int i = 0; i < n-1; i++) {
if (u[i] > v[i]) swap(u[i], v[i]);
binary &= (v[i] + 1) / 2 == (u[i] + 1);
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
int r = -1;
for (int i = 0; i < n; i++) {
if (adj[i].size() == 1) r = i;
line &= adj[i].size() <= 2;
}
if (line) {
vector<int> ans(n);
int t = 0;
auto dfs = [&](auto&& s, int v, int p) -> void {
ans[v] = t++;
for (int u : adj[v]) if (u != p) s(s, u, v);
};
dfs(dfs, r, -1);
return ans;
}
if (binary) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) go[i][j] = -1;
auto dfs = [&](auto&& s, int v) -> void {
for (int u : adj[v]) if (u != go[i][v]) {
go[i][u] = v;
s(s, u);
}
};
dfs(dfs, i);
}
vector<int> ans(n);
iota(ans.begin(), ans.end(), 0);
return ans;
}
return {};
}
int find_next_station(int s, int t, std::vector<int> c) {
if (line) {
for (int x : c) if ((x-s)*(x-t) <= 0) return x;
}
if (binary) {
return go[t][s];
}
assert(0);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
352 ms |
8624 KB |
Output is correct |
2 |
Correct |
262 ms |
8620 KB |
Output is correct |
3 |
Correct |
530 ms |
8364 KB |
Output is correct |
4 |
Correct |
381 ms |
8360 KB |
Output is correct |
5 |
Correct |
358 ms |
8364 KB |
Output is correct |
6 |
Correct |
291 ms |
8620 KB |
Output is correct |
7 |
Correct |
244 ms |
8620 KB |
Output is correct |
8 |
Correct |
5 ms |
8464 KB |
Output is correct |
9 |
Correct |
5 ms |
8452 KB |
Output is correct |
10 |
Correct |
4 ms |
8456 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
306 ms |
8624 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
314 ms |
8620 KB |
Output is correct |
2 |
Correct |
238 ms |
8620 KB |
Output is correct |
3 |
Correct |
492 ms |
8364 KB |
Output is correct |
4 |
Correct |
410 ms |
8364 KB |
Output is correct |
5 |
Correct |
379 ms |
8364 KB |
Output is correct |
6 |
Correct |
261 ms |
8652 KB |
Output is correct |
7 |
Correct |
284 ms |
8620 KB |
Output is correct |
8 |
Correct |
4 ms |
8448 KB |
Output is correct |
9 |
Correct |
5 ms |
8456 KB |
Output is correct |
10 |
Correct |
4 ms |
8848 KB |
Output is correct |
11 |
Incorrect |
2 ms |
4396 KB |
Invalid length of array as the response of 'label'. scenario=1, n=4, len=0 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
520 ms |
8364 KB |
Output is correct |
2 |
Correct |
418 ms |
8364 KB |
Output is correct |
3 |
Correct |
365 ms |
8364 KB |
Output is correct |
4 |
Correct |
4 ms |
8464 KB |
Output is correct |
5 |
Correct |
5 ms |
8464 KB |
Output is correct |
6 |
Correct |
4 ms |
8456 KB |
Output is correct |
7 |
Incorrect |
2 ms |
4184 KB |
Invalid length of array as the response of 'label'. scenario=0, n=4, len=0 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
315 ms |
8620 KB |
Output is correct |
2 |
Correct |
230 ms |
8620 KB |
Output is correct |
3 |
Correct |
560 ms |
8364 KB |
Output is correct |
4 |
Correct |
391 ms |
8364 KB |
Output is correct |
5 |
Correct |
314 ms |
8364 KB |
Output is correct |
6 |
Correct |
244 ms |
8620 KB |
Output is correct |
7 |
Correct |
245 ms |
8620 KB |
Output is correct |
8 |
Correct |
4 ms |
8436 KB |
Output is correct |
9 |
Correct |
5 ms |
8464 KB |
Output is correct |
10 |
Correct |
4 ms |
8456 KB |
Output is correct |
11 |
Incorrect |
328 ms |
8620 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |