Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cinng(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfng(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
#define over(A) {cout<<A<<endl;exit(0);}
typedef unsigned long long ull;
const int inf=1039704182;
using namespace std;
int n,m;
vector <pii> vec[100005];
set <pair<pii,int> > squ;
unordered_map <pii,int> dist;

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n>>m;
	int x,y,z;
	for(int i=0;i<m;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		x--;
		y--;
		vec[x].push_back(mp(y,z));
		vec[y].push_back(mp(x,z));
	}
	squ.insert(mp(mp(0,0),0));//distance, position and company.
	while(squ.size())
	{
		int x=squ.begin()->first.second;
		int d=squ.begin()->first.first;
		int boss=squ.begin()->second;
		squ.erase(mp(mp(d,x),boss));
		int c;
		if(boss==0)
		{
			for(int i=0;i<vec[x].size();i++)
			{
				c=vec[x][i].second;
				if(dist.find(mp(vec[x][i].first,c))==dist.end() || dist[mp(vec[x][i].first,c)]>d+1)
				{
					dist[mp(vec[x][i].first,c)]=d+1;
					squ.insert(mp(mp(d+1,vec[x][i].first),c));
				}
			}
		}
		else
		{
			if(dist.find(mp(x,0))==dist.end() || dist[mp(x,0)]>d)
			{
				dist[mp(x,0)]=d;
				squ.insert(mp(mp(d,x),0));
			}
			for(int i=0;i<vec[x].size();i++)
			{
				if(vec[x][i].second!=boss) continue;
				if(dist.find(mp(vec[x][i].first,boss))==dist.end() || dist[mp(vec[x][i].first,boss)]>d)
				{
					dist[mp(vec[x][i].first,boss)]=d;
					squ.insert(mp(mp(d,vec[x][i].first),boss));
				}
			}
		}
	}
	int res=inf;
	for(int i=0;i<1000000;i++)
	{
		if(dist.find(mp(n-1,i))==dist.end()) continue;
		res=min(res,dist[mp(n-1,i)]);
	}
	cout<<(res==inf?-1:res)<<endl;
	return 0;
}

Compiler output:
a.cc:32:1: error: 'unordered_map' does not name a type
   32 | unordered_map <pii,int> dist;
      | ^~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:60:36: error: 'dist' was not declared in this scope
   60 |                                 if(dist.find(mp(vec[x][i].first,c))==dist.end() || dist[mp(vec[x][i].first,c)]>d+1)
      |                                    ^~~~
a.cc:69:28: error: 'dist' was not declared in this scope
   69 |                         if(dist.find(mp(x,0))==dist.end() || dist[mp(x,0)]>d)
      |                            ^~~~
a.cc:77:36: error: 'dist' was not declared in this scope
   77 |                                 if(dist.find(mp(vec[x][i].first,boss))==dist.end() || dist[mp(vec[x][i].first,boss)]>d)
      |                                    ^~~~
a.cc:88:20: error: 'dist' was not declared in this scope
   88 |                 if(dist.find(mp(n-1,i))==dist.end()) continue;
      |                    ^~~~
a.cc:89:29: error: 'dist' was not declared in this scope
   89 |                 res=min(res,dist[mp(n-1,i)]);
      |                             ^~~~