#include<bits/stdc++.h>
#include "crocodile.h"
#define ll long long int
#define pb push_back
#define mp make_pair
#define FOR(i,n) for(i=0;i<(n);++i)
#define FORe(i,n) for(i=1;i<=(n);++i)
#define FORr(i,a,b) for(i=(a);i<(b);++i)
#define FORrev(i,n) for(i=(n);i>=0;--i)
#define ii pair<ll,ll>
#define vi vector<ll>
#define vii vector<ii>
#define ff first
#define ss second
#define cd complex<double>
#define vcd vector<cd>
#define ldd long double
#define dbgLine cout<<"Line : "<<__LINE__<<'\n'
#define all(x) (x).begin(),(x).end()
using namespace std;
/*
const short int __PRECISION = 10;
const ll MOD = 1e9+7;
const ll INF = 1e17 + 1101;
const ll LOGN = 17;
const ll MAXN = 2e5+5;
const ll ROOTN = 320;
const ldd PI = acos(-1);
const ldd EPS = 1e-7;
*/
struct edge
{
ll to, wt, ind;
inline void reset(){to = -1; wt = -1; ind = -1;}
inline void set(ll t, ll w, ll in){to = t; wt = w; ind = in;}
} Neutral;
int travel_plan(int N,int M,int* R[],int* L,int K,int* P)
{
vector<edge> g[N+1];
ll towards[N+1], i, d[N+1], d2[N+1];
bool open[M+K+1];
Neutral.reset();
FOR(i, N)
d[i] = d2[i] = 1e9 + 2;
d[N] = d2[N] = 0;
FOR(i, M)
{
g[R[i][0]].pb(Neutral);
g[R[i][1]].pb(Neutral);
g[R[i][0]][g[R[i][0]].size() - 1].set(R[i][1], L[i], i);
g[R[i][1]][g[R[i][1]].size() - 1].set(R[i][0], L[i], i);
open[i] = true;
}
FOR(i, K)
{
g[P[i]].pb(Neutral);
g[N].pb(Neutral);
g[P[i]][g[P[i]].size() - 1].set(N, 0, i + M);
g[N][g[N].size() - 1].set(P[i], 0, i + M);
R.pb({N, P[i]});
open[i + M] = true;
}
set<ii> x; // (d,vertex);
x.insert(mp(0,N));
set<ii> :: iterator it;
while(!x.empty())
{
int a = (*(x.begin())).ss;
x.erase(x.begin());
for(edge pp : g[a])
{
if (d[pp.to] > d[a] + pp.wt)
{
x.erase(mp(d[pp.to],pp.to));
d[pp.to] = d[a] + pp.wt;
x.insert(mp(d[pp.to],pp.to));
towards[pp.to] = pp.ind;
}
}
}
FOR(i, N)
if(towards[i] < M)
open[towards[i]] = false;
// FOR(i, N)
// cout<<i<<" -> "<<((towards[i] < M) ? (R[towards[i]][0] + R[towards[i]][1] - i) : -1 )<<"\t d["<<i<<"] = "<<d[i]<<'\n';
x.clear();
x.insert(mp(0,N));
while(!x.empty())
{
// cout<<"x contains : "; for(ii vv : x) cout<<vv.ff<<' '<<vv.ss<<'\t'; cout<<endl;
int a = (*(x.begin())).ss;
x.erase(x.begin());
for(edge pp : g[a])
{
if (open[pp.ind] && d2[pp.to] > d2[a] + pp.wt)
{
// cout<<"updating "<<pp.to<<" from "<<a<<endl;
x.erase(mp(d2[pp.to],pp.to));
d2[pp.to] = d2[a] + pp.wt;
x.insert(mp(d2[pp.to],pp.to));
}
}
}
return d2[0];
}
Compilation message
crocodile.cpp: In function 'int travel_plan(int, int, int**, int*, int, int*)':
crocodile.cpp:5:12: error: request for member 'push_back' in 'R', which is of non-class type 'int**'
#define pb push_back
^
crocodile.cpp:65:5: note: in expansion of macro 'pb'
R.pb({N, P[i]});
^~