Language: C++

/*
 * src.cpp
 *
 *  Created on: 2016/09/11
 *      Author: joi
 */

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

typedef long long ll;
typedef pair<int,int> P;

const int MAX_N=1e5,INF=1e8;

struct edge{
	int to,type;
};

struct S{
	int v,type,cost;
	bool operator < (const S &s){
		return cost>s.cost;
	}
};

int N,M;
vector<edge> G[MAX_N];

map<int,int> d[MAX_N];	//乗り換えの回数

void dijkstra(){
	priority_queue<S> pq;
	d[0][-1]=0;
	pq.push(S{0,-1,0});
	while (!pq.empty()){
		S p=pq.top();
		pq.pop();
		if (d[p.v][p.type]<p.cost){
			continue;
		}
		REP(i,(int)G[p.v]){
			edge e=G[p.v][i];
			int c=p.cost;
			int f=0;
			if (e.type!=p.type){
				c++;
				f=1;
			}
			if (d[e.to].find(c)==d[e.to].end() || d[e.to][c]>p.cost+f){
				d[e.to][c]=p.cost+f;
				pq.push(S{e.to,e.type,d[e.to][c]});
			}
		}
	}
}

int main(){
	scanf("%d %d",&N,&M);
	REP(i,M){
		int p,q,c;
		p--;
		q--;
		G[p].push_back(edge{q,c});
		G[q].push_back(edge{p,c});
	}
	dijkstra();
	int ans=INF;
	for (auto ite=d[N-1].begin();ite!=d[N-1].end();ite++){
		ans=min(ans,ite->second);
	}
	printf("%d\n",ans);
	return 0;
}


Compiler output:
a.cc: In function 'void dijkstra()':
a.cc:46:23: error: invalid cast from type 'std::vector<edge>' to type 'int'
   46 |                 REP(i,(int)G[p.v]){
      |                       ^~~~~~~~~~~
a.cc:12:37: note: in definition of macro 'FOR'
   12 | #define FOR(i,a,b) for(int i=(a);i<(b);i++)
      |                                     ^
a.cc:46:17: note: in expansion of macro 'REP'
   46 |                 REP(i,(int)G[p.v]){
      |                 ^~~
In file included from /usr/include/c++/14/string:49,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:8:
/usr/include/c++/14/bits/stl_function.h: In instantiation of 'constexpr bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = S]':
/usr/include/c++/14/bits/predefined_ops.h:196:23:   required from 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<S*, std::vector<S, std::allocator<S> > >; _Value = S; _Compare = std::less<S>]'
  196 |         { return bool(_M_comp(*__it, __val)); }
      |                       ~~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:140:48:   required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<S*, vector<S, allocator<S> > >; _Distance = long int; _Tp = S; _Compare = __gnu_cxx::__ops::_Iter_comp_val<less<S> >]'
  140 |       while (__holeIndex > __topIndex && __comp(__first + __parent, __value))
      |                                          ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:216:23:   required from 'void std::push_heap(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<S*, vector<S, allocator<S> > >; _Compare = less<S>]'
  216 |       std::__push_heap(__first, _DistanceType((__last - __first) - 1),
      |       ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  217 |                        _DistanceType(0), _GLIBCXX_MOVE(__value), __cmp);
      |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:747:16:   required from 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = S; _Sequence = std::vector<S, std::allocator<S> >; _Compare = std::less<S>; value_type = S]'
  747 |         std::push_heap(c.begin(), c.end(), comp);
      |         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:39:9:   required from here
   39 |         pq.push(S{0,-1,0});
      |         ~~~~~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_function.h:405:20: error: no match for 'operator<' (operand types are 'const S' and 'const S')
  405 |       { return __x < __y; }
      |                ~~~~^~~~~
a.cc:26:14: note: candidate: 'bool S::operator<(const S&)' (near match)
   26 |         bool operator < (const S &s){
      |              ^~~~~~~~
a.cc:26:14: note:   passing 'const S*' as 'this' argument discards qualifiers
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
 1045 |     operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1045:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note:   'const S' is not derived from 'const std::pair<_T1, _T2>'
  405 |       { return __x < __y; }
      |                ~~~~^~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
  448 |     operator<(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note:   'const S' is not derived from 'const std::reverse_iterator<_Iterator>'
  405 |       { return __x < __y; }
      |                ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  493 |     operator<(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note:   'const S' is not derived from 'const std::reverse_iterator<_Iterator>'
  405 |       { return __x < __y; }
      |                ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1694 |     operator<(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note:   'const S' is not derived from 'const std::move_iterator<_IteratorL>'
  405 |       { return __x < __y; }
      |                ~~~~^~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
 1760 |     operator<(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_function.h:405:20: note:   'const S' is not derived from 'const std::move_iterator<_IteratorL>'
  405 |       { return __x < __y; }
      |                ~~~~^~~~~