Language: C++

# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<long long>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
int h, w, n, m, k, s, t, q, last, cnt, sum, ans, d[400000];
string str, ss;
bool f;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 } ,{ 0,-1 } };
struct Edge { int to, cost; };
vector<Edge>vec[200000];
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
void dijk(LL s) {
	for (LL i = 0; i < 400000; i++)
		d[i] = INF;
	d[s] = 0;
	priority_queue<Ppll, vector<Ppll>, greater<Ppll>> pq;
	pq.push(Ppll(d[s], Pll(s, -1))); // (cost,頂点番号) 
	while (!pq.empty()) {
		Ppll pp;
		pp = pq.top();
		LL cos = pp.first, vv = pp.second.fir, com = pp.sec.sec;
		pq.pop();
		if (d[vv] < pp.first)continue;
		if (com == -1) {
			d[vv] = min(d[vv], cos + 1);
			cos = d[vv];
		}
		for (int i = 0; i < vec[vv].size(); i++) {
			if (com == -1) {
				if (cos + 1 < d[vec[vv][i].to]) {
					pq.push(Ppll(cos, Pll(vec[vv][i].to, vec[vv][i].cost)));
				}
			}
			else {
				if (com == vec[vv][i].cost || vec[vv][i].cost == -1) {
					if (cos + 1 < d[vec[vv][i].to]) {
						pq.push(Ppll(cos, Pll(vec[vv][i].to, vec[vv][i].cost)));
					}
				}
			}
		}
	}
}

int main() {
	cin >> n >> m;
	rep(i, m) {
		LL x, y, z;
		cin >> x >> y >> z;
		x--, y--;
		vec[x].push_back(Edge{ y,z });
		vec[y].push_back(Edge{ x,z });
	}
	rep(i, n)
		vec[i].push_back(Edge{ i,-1 });
	dijk(0);
	cout << (d[n - 1] == INF ? -1 : d[n - 1]) << endl;
	return 0;
}

Compiler output:
a.cc: In function 'void dijk(LL)':
a.cc:75:24: warning: overflow in conversion from 'long long int' to 'int' changes value from '9223372036854775807' to '-1' [-Woverflow]
   75 |                 d[i] = INF;
      |                        ^~~
a.cc:86:36: error: no matching function for call to 'min(int&, LL)'
   86 |                         d[vv] = min(d[vv], cos + 1);
      |                                 ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:86:36: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'LL' {aka 'long long int'})
   86 |                         d[vv] = min(d[vv], cos + 1);
      |                                 ~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:86:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   86 |                         d[vv] = min(d[vv], cos + 1);
      |                                 ~~~^~~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:112:40: warning: narrowing conversion of 'y' from 'LL' {aka 'long long int'} to 'int' [-Wnarrowing]
  112 |                 vec[x].push_back(Edge{ y,z });
      |                                        ^
a.cc:112:42: warning: narrowing conversion of 'z' from 'LL' {aka 'long long int'} to 'int' [-Wnarrowing]
  112 |                 vec[x].push_back(Edge{ y,z });
      |                                          ^
a.cc:113:40: warning: narrowing conversion of 'x' from 'LL' {aka 'long long int'} to 'int' [-Wnarrowing]
  113 |                 vec[y].push_back(Edge{ x,z });
      |                                        ^
a.cc:113:42: warning: narrowing conversion of 'z' from 'LL' {aka 'long long int'} to 'int' [-Wnarrowing]
  113 |                 vec[y].push_back(Edge{ x,z });
      |                                          ^
a.cc:116:40: warning: narrowing conversion of 'i' from 'LL' {aka 'long long int'} to 'int' [-Wnarrowing]
  116 |                 vec[i].push_back(Edge{ i,-1 });
      |                                        ^