#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);
}
Compilation message
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:19:6: warning: variable 'r' set but not used [-Wunused-but-set-variable]
19 | int r = -1;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
4436 KB |
Invalid length of array as the response of 'label'. scenario=0, n=10, len=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
322 ms |
8616 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
4440 KB |
Invalid length of array as the response of 'label'. scenario=1, n=997, len=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
495 ms |
8364 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
4184 KB |
Invalid length of array as the response of 'label'. scenario=0, n=3, len=0 |
2 |
Halted |
0 ms |
0 KB |
- |