Language: C++


#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
using R = double;
using Data = pair < ll, vector <ll>>;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 60;
struct edge { ll from; ll to; ll cost; };
typedef pair<ll, ll>pll;
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2

int N, M;
vector<pair<int, int>>e[101010];
ll dist[101010];
int used[101010];
void dijkstra() {
	rep(i, 0, 101010)dist[i] = inf;
	dist[0] = 0;
	min_priority_queue<tuple<ll,ll,ll>>q;
	q.push((0,0,-1));
	while (q.size()) {
		auto p = q.top();
		q.pop();
		ll d = get<0>(p);
		int cur = get<1>(p);
		int last = get<2>(p);
		if (used[cur])continue;
		used[cur] = 1;
		fore(x,e[cur]) {
			ll cc = d + ((x.second == last) ? 0 : 1);
			if (cc < dist[x.first]) {
				dist[x.first] = cc;
				q.push(( cc,x.first,x.second ));
			}
		}
	}
}

int main() {
	cin >> N >> M;
	rep(i, 0, M) {
		int p, q, r;
		cin >> p >> q >> r;
		p--, q--;
		e[p].pb({ q,r });
		e[q].pb({ p,r });
	}
	dijkstra();
	if (dist[N - 1] == inf) {
		cout << -1 << endl;
	}
	else {
		cout << dist[N - 1] << endl;
	}
	return 0;
}


Compiler output:
a.cc: In function 'void dijkstra()':
a.cc:48:15: error: no matching function for call to 'std::priority_queue<std::tuple<long long int, long long int, long long int>, std::vector<std::tuple<long long int, long long int, long long int>, std::allocator<std::tuple<long long int, long long int, long long int> > >, std::greater<std::tuple<long long int, long long int, long long int> > >::push(int)'
   48 |         q.push((0,0,-1));
      |         ~~~~~~^~~~~~~~~~
In file included from /usr/include/c++/14/queue:66,
                 from a.cc:18:
/usr/include/c++/14/bits/stl_queue.h:736:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::tuple<long long int, long long int, long long int>; _Sequence = std::vector<std::tuple<long long int, long long int, long long int>, std::allocator<std::tuple<long long int, long long int, long long int> > >; _Compare = std::greater<std::tuple<long long int, long long int, long long int> >; value_type = std::tuple<long long int, long long int, long long int>]'
  736 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:736:30: note:   no known conversion for argument 1 from 'int' to 'const std::priority_queue<std::tuple<long long int, long long int, long long int>, std::vector<std::tuple<long long int, long long int, long long int>, std::allocator<std::tuple<long long int, long long int, long long int> > >, std::greater<std::tuple<long long int, long long int, long long int> > >::value_type&' {aka 'const std::tuple<long long int, long long int, long long int>&'}
  736 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_queue.h:744:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = std::tuple<long long int, long long int, long long int>; _Sequence = std::vector<std::tuple<long long int, long long int, long long int>, std::allocator<std::tuple<long long int, long long int, long long int> > >; _Compare = std::greater<std::tuple<long long int, long long int, long long int> >; value_type = std::tuple<long long int, long long int, long long int>]'
  744 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:744:25: note:   no known conversion for argument 1 from 'int' to 'std::priority_queue<std::tuple<long long int, long long int, long long int>, std::vector<std::tuple<long long int, long long int, long long int>, std::allocator<std::tuple<long long int, long long int, long long int> > >, std::greater<std::tuple<long long int, long long int, long long int> > >::value_type&&' {aka 'std::tuple<long long int, long long int, long long int>&&'}
  744 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
a.cc:61:39: error: no matching function for call to 'std::priority_queue<std::tuple<long long int, long long int, long long int>, std::vector<std::tuple<long long int, long long int, long long int>, std::allocator<std::tuple<long long int, long long int, long long int> > >, std::greater<std::tuple<long long int, long long int, long long int> > >::push(int&)'
   61 |                                 q.push(( cc,x.first,x.second ));
      |                                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:736:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::tuple<long long int, long long int, long long int>; _Sequence = std::vector<std::tuple<long long int, long long int, long long int>, std::allocator<std::tuple<long long int, long long int, long long int> > >; _Compare = std::greater<std::tuple<long long int, long long int, long long int> >; value_type = std::tuple<long long int, long long int, long long int>]'
  736 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:736:30: note:   no known conversion for argument 1 from 'int' to 'const std::priority_queue<std::tuple<long long int, long long int, long long int>, std::vector<std::tuple<long long int, long long int, long long int>, std::allocator<std::tuple<long long int, long long int, long long int> > >, std::greater<std::tuple<long long int, long long int, long long int> > >::value_type&' {aka 'const std::tuple<long long int, long long int, long long int>&'}
  736 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_queue.h:744:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = std::tuple<long long int, long long int, long long int>; _Sequence = std::vector<std::tuple<long long int, long long int, long long int>, std::allocator<std::tuple<long long int, long long int, long long int> > >; _Compare = std::greater<std::tuple<long long int, long long int, long long int> >; value_type = std::tuple<long long int, long long int, long long int>]'
  744 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:744:25: note:   no known conversion for argument 1 from 'int' to 'std::priority_queue<std::tuple<long long int, long long int, long long int>, std::vector<std::tuple<long long int, long long int, long long int>, std::allocator<std::tuple<long long int, long long int, long long int> > >, std::greater<std::tuple<long long int, long long int, long long int> > >::value_type&&' {aka 'std::tuple<long long int, long long int, long long int>&&'}
  744 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~