#include "stations.h"
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=1e3+7;
int pre[LIM], post[LIM], lpre, lpost;
vector<int>label(int n, int k, vector<int>u, vector<int>v) {
vector<int>ans(n), V[n];
rep(i, n-1) {
V[u[i]].pb(v[i]);
V[v[i]].pb(u[i]);
}
queue<int>q;
q.push(0);
while(!q.empty()) {
int p=q.top();
if(pre[p]) {
++lpost;
post[p]=lpost;
q.pop();
continue;
}
++lpre;
pre[p]=lpre;
for(auto i : V[p]) if(!pre[i]) q.push(i);
}
rep(i, n) ans[i]=i;
return ans;
}
int find_next_station(int s, int t, vector<int>c) {
int ojciec=-1;
for(auto i : c) if(pre[i]<pre[s]) ojciec=i;
for(auto i : c) if(i!=ojciec && pre[i]<=pre[t] && post[i]>=post[t]) return i;
return ojciec;
}
Compilation message
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:21:11: error: 'class std::queue<int>' has no member named 'top'; did you mean 'pop'?
21 | int p=q.top();
| ^~~
| pop