Language: C++

#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

vector< vector<edge_base> > gra;
int use_color = -2;
set<int> visit;
void dfs(int curr,int prev,int prev_color,int set_color){
	int size = gra[curr].size();
	for(int i=0;i<size;++i){
		int to = gra[curr][i].to;
		if( curr == to ) continue;//戻らない
		int color = gra[curr][i].cost;
		if( color < 0 ){//乗り換え済み
			continue;
		}
		if( prev_color == -1 ){
			visit.insert( to );
			gra[curr][i].cost = use_color;//連結成分にする。
			dfs( to, curr, color, use_color );
			--use_color;
		}else if( prev_color == color ){
			gra[curr][i].cost = use_color;
			visit.insert( to );
			dfs( to, curr, color, use_color );
		}
	}
}
void solve(){
	int N,M;
	cin >> N >> M;
	gra.resize(N);

	while(M--){
		int P,Q,C;
		cin >> P >> Q >> C;
		--P;--Q;
		gra[P].push_back( make_edge_base(Q,C) );
		gra[Q].push_back( make_edge_base(P,C) );
	}
	////
	int visit_num = 1;//0番には行っている。
	vector<bool> start(N,false);
	set<int> next;
	next.insert(0);
	int ans = 0;
	while( next.size() != 0){
		++ans;
		set<int>::iterator itr,end;
		itr = next.begin();
		end = next.end();
		for(;itr!=end;++itr){
			dfs( *itr,-1,-1,-1);
		}
		if( visit.find(N-1) != visit.end() ){
			cout << ans << endl;
			return;
		}
		{
			set<int> zero;
			next = visit;
			visit = zero;
		}
	}
	cout << -1 << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Compiler output:
a.cc:50:16: error: 'edge_base' was not declared in this scope
   50 | vector< vector<edge_base> > gra;
      |                ^~~~~~~~~
a.cc:50:25: error: template argument 1 is invalid
   50 | vector< vector<edge_base> > gra;
      |                         ^
a.cc:50:25: error: template argument 2 is invalid
a.cc:50:27: error: template argument 1 is invalid
   50 | vector< vector<edge_base> > gra;
      |                           ^
a.cc:50:27: error: template argument 2 is invalid
a.cc: In function 'void dfs(int, int, int, int)':
a.cc:54:23: error: invalid types 'int[int]' for array subscript
   54 |         int size = gra[curr].size();
      |                       ^
a.cc:56:29: error: invalid types 'int[int]' for array subscript
   56 |                 int to = gra[curr][i].to;
      |                             ^
a.cc:58:32: error: invalid types 'int[int]' for array subscript
   58 |                 int color = gra[curr][i].cost;
      |                                ^
a.cc:64:28: error: invalid types 'int[int]' for array subscript
   64 |                         gra[curr][i].cost = use_color;//連結成分にする。
      |                            ^
a.cc:68:28: error: invalid types 'int[int]' for array subscript
   68 |                         gra[curr][i].cost = use_color;
      |                            ^
a.cc: In function 'void solve()':
a.cc:77:13: error: request for member 'resize' in 'gra', which is of non-class type 'int'
   77 |         gra.resize(N);
      |             ^~~~~~
a.cc:83:20: error: invalid types 'int[int]' for array subscript
   83 |                 gra[P].push_back( make_edge_base(Q,C) );
      |                    ^
a.cc:83:35: error: 'make_edge_base' was not declared in this scope
   83 |                 gra[P].push_back( make_edge_base(Q,C) );
      |                                   ^~~~~~~~~~~~~~
a.cc:84:20: error: invalid types 'int[int]' for array subscript
   84 |                 gra[Q].push_back( make_edge_base(P,C) );
      |                    ^