#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1011;
vector<int> g[MAXN];
int tin[MAXN], last[MAXN], timer = 0;
void dfs(int v, int p){
tin[v] = last[v] = timer++;
for (int u : g[v]){
if (u != p){
dfs(u, v);
last[v] = last[u];
}
}
}
bool line = true, binary = true;
vector<int> label(int n, int k, vector<int> U, vector<int> V) {
for (int i = 0; i < n; i++) g[i].clear();
timer = 0;
for (int i = 0; i < n - 1; i++){
if (U[i] > V[i]) swap(U[i], V[i]);
g[U[i]].push_back(V[i]);
g[V[i]].push_back(U[i]);
if (U[i] != i / 2 || V[i] != i + 1) binary = false;
}
int idx = -1;
for (int i = 0; i < n; i++){
if (g[i].size() > 2){
line = false;
}
if (g[i].size() == 1) idx = i;
}
dfs(idx, -1);
vector<int> labels(n, 0);
for (int i = 0; i < n; i++){
if (line){
labels[i] = tin[i];
continue;
}
if (binary){
labels[i] = i;
continue;
}
labels[i] = tin[i] * 1000 + last[i];
}
return labels;
}
int find_next_station(int s, int t, vector<int> c) {
if (true){
while (t > 0){
int x = (t - 1) / 2;
if (x == s) return t;
t = x;
}
return (s - 1) / 2;
}
if (line){
return (s < t ? s + 1 : s - 1);
}
int ans = c[0];
t /= 1000;
for (int v : c){
int x = v / 1000, y = v % 1000;
if (x <= t && t <= y) ans = v;
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
684 ms |
520 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
573 ms |
520 KB |
Output is correct |
2 |
Correct |
606 ms |
528 KB |
Output is correct |
3 |
Correct |
1071 ms |
400 KB |
Output is correct |
4 |
Incorrect |
885 ms |
400 KB |
Wrong query response. |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
622 ms |
528 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
994 ms |
528 KB |
Output is correct |
2 |
Incorrect |
773 ms |
400 KB |
Wrong query response. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
635 ms |
520 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |