#include "stations.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
struct graph{
int n;
vector<vector<int>> v;
graph(){}
graph(int nn, vector<int> aa, vector<int> bb){
n = nn;
v.assign(n, {});
for(int i = 0; i < n-1; i++){
v[aa[i]].pb(bb[i]);
v[bb[i]].pb(aa[i]);
}
}
};
int r = 0, rr = 0;
vector<graph> g(10);
vector<int> gg;
vector<int> label(int n, int k, vector<int> aa, vector<int> bb){
g[r++] = graph(n, aa, bb);
vector<int> lb(n);
for(int i = 0; i < n; i++) lb[i] = rr++;
gg.pb(rr);
return lb;
}
vector<int> cur;
int ans;
void dfs(int nd, int ss, int tt, graph gr){
if(nd == tt){
ans = cur.front();
return;
}
if(ans != -1) return;
for(int x: gr.v[nd]) if(x!=ss){
cur.pb(x);
dfs(x, nd, tt, gr);
cur.pop_back();
}
}
int find_next_station(int s, int t, vector<int> c){
cur.clear();
ans = -1;
int gi = upper_bound(gg.begin(), gg.end(), s) - gg.begin();
dfs(s, -1, t, g[gi]);
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
620 KB |
Invalid labels (values out of range). scenario=2, k=1000, vertex=988, label=1001 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
876 KB |
Invalid labels (values out of range). scenario=1, k=1000, vertex=5, label=1001 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
1388 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
1104 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
1120 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |