#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){
n = nn;
v.assign(n, {});
}
void add(vector<int> aa, vector<int> bb){
for(int i = 0; i < aa.size(); i++){
v[aa[i]].pb(bb[i]);
v[bb[i]].pb(aa[i]);
}
}
}g(1e5);
int r = 0, rr = 0;
vector<int> label(int n, int k, vector<int> aa, vector<int> bb){
vector<int> lb(n);
for(int i = 0; i < n; i++) lb[i] = rr++;
for(int i = 0; i < n-1; i++) aa[i] = lb[aa[i]], bb[i] = lb[bb[i]];
g.add(aa, bb);
return lb;
}
vector<int> cur;
int ans;
void dfs(int nd, int ss, int tt){
if(nd == tt){
ans = cur.front();
return;
}
if(ans != -1) return;
for(int x: g.v[nd]) if(x!=ss){
cur.pb(x);
dfs(x, nd, tt);
cur.pop_back();
}
}
int find_next_station(int s, int t, vector<int> c){
cur.clear();
ans = -1;
dfs(s, -1, t);
return ans;
}
Compilation message
stations.cpp: In member function 'void graph::add(std::vector<int>, std::vector<int>)':
stations.cpp:18:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
18 | for(int i = 0; i < aa.size(); i++){
| ~~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
2796 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 |
7 ms |
3116 KB |
Invalid labels (values out of range). scenario=1, k=1000, vertex=5, label=1001 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
642 ms |
5600 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1093 ms |
5728 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
605 ms |
5600 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |