#include<bits/stdc++.h>
#include "stations.h"
using namespace std;
constexpr int N = 2005;
int timer;
vector<int> l, d;
vector<bool> visited;
vector<vector<int> > edges;
void dfs(int id){
visited[id] = 1;
d[id] = timer++;
for(int v : edges[id]){
if(!visited[v]) dfs(v);
}
l[id] = timer++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v){
edges.resize(n, vector<int>());
visited.resize(n, 0);
l.resize(n);
d.resize(n);
vector<int> ll(n);
for(int i = 0; i < n; i++){
edges[u[i]].push_back(v[i]);
edges[v[i]].push_back(u[i]);
}
dfs(0);
for(int i = 0; i < n; i++){
ll[i] = N * d[i] + l[i];
}
edges.clear();
visited.clear();
l.clear();
d.clear();
timer = 0;
return ll;
}
int find_next_station(int s, int t, std::vector<int> c){
int si = s / N, sl = s % N, ti = t / N, tl = t % N, dex = -1;
vector<int> v;
v.reserve(c.size());
for(int x : c){
int ci = x / N, cl = x % N;
if(ci <= si && sl <= cl) dex = x;
}
int dex = min_element(v.begin(), v.end()) - v.begin();
for(int x : c){
int ci = x / N, cl = x % N;
if(x != dex && ci <= ti && tl <= cl) return x;
}
return dex;
}
/*
int main(){
vector<int> v(9), u(9);
v[1] = 9;
iota(v.begin(), v.end(), 0);
fill(u.begin(), u.begin() + 5, 1);
fill(u.begin() + 5, u.begin() + 9, 0);
vector<int> c = label(10, 1000000, u, v);
vector<int> ad;
for(int x : edges[0]) ad.push_back(c[x]);
int x = find_next_station(c[0], c[9], ad);
cout << (int)(find(c.begin(), c.end(), x) - c.begin()) << endl;
}
*/
Compilation message
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:50:9: error: redeclaration of 'int dex'
50 | int dex = min_element(v.begin(), v.end()) - v.begin();
| ^~~
stations.cpp:43:57: note: 'int dex' previously declared here
43 | int si = s / N, sl = s % N, ti = t / N, tl = t % N, dex = -1;
| ^~~