Language: C++

#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define inf 1e9+7
using namespace std;
int n,m,dist[300005],hash[300005]={};
vector<pii > g[100005],gg[300005];//first:val
vector<int> col[200005];
priority_queue<pii >q;
void dfs(int s,int col,int now){
	hash[s]=col;
	gg[s].pb(mp(1,now));
	gg[now].pb(mp(0,s));
	for(int i=0;i<g[s].size();i++)
	if(g[s][i].first==col&&hash[g[s][i].second]!=col) dfs(g[s][i].second,col,now);
}
void dij(){
	q.push(mp(0,1));
	memset(hash,0,sizeof(hash));
	for(int i=1;i<=m+n;i++) dist[i]=inf;
	dist[1]=0;
	while(!q.empty()){
		int v=q.top().second;
		q.pop();
		if(v==n) return;
		if(hash[v]==0){
			hash[v]=1;
			for(int i=0;i<gg[v].size();i++)
			if(dist[v]+gg[v][i].first<dist[gg[v][i].second]){
				dist[gg[v][i].second]=dist[v]+gg[v][i].first;
				q.push(mp(-dist[gg[v][i].second],gg[v][i].second));
			}
		}
	}
}
int main(){
	freopen("ini.txt","r",stdin);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int f,r,val;
		scanf("%d%d%d",&f,&r,&val);
		g[f].pb(mp(val,r));
		g[r].pb(mp(val,f));
		col[val].pb(f);
		col[val].pb(r);
	}
	int now=n+1;
	for(int i=1;i<=m;i++)
	for(int j=0;j<col[i].size();j++)
	if(hash[col[i][j]]!=i){
		dfs(col[i][j],i,now);
		now++;
	}
	dij();
	if(dist[n]==inf) puts("-1");
	else printf("%d\n",dist[n]);
	return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int, int)':
a.cc:12:9: error: reference to 'hash' is ambiguous
   12 |         hash[s]=col;
      |         ^~~~
In file included from /usr/include/c++/14/string_view:50,
                 from /usr/include/c++/14/bits/basic_string.h:47,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:7:22: note:                 'int hash [300005]'
    7 | int n,m,dist[300005],hash[300005]={};
      |                      ^~~~
a.cc:16:32: error: reference to 'hash' is ambiguous
   16 |         if(g[s][i].first==col&&hash[g[s][i].second]!=col) dfs(g[s][i].second,col,now);
      |                                ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:7:22: note:                 'int hash [300005]'
    7 | int n,m,dist[300005],hash[300005]={};
      |                      ^~~~
a.cc: In function 'void dij()':
a.cc:20:16: error: reference to 'hash' is ambiguous
   20 |         memset(hash,0,sizeof(hash));
      |                ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:7:22: note:                 'int hash [300005]'
    7 | int n,m,dist[300005],hash[300005]={};
      |                      ^~~~
a.cc:20:30: error: reference to 'hash' is ambiguous
   20 |         memset(hash,0,sizeof(hash));
      |                              ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:7:22: note:                 'int hash [300005]'
    7 | int n,m,dist[300005],hash[300005]={};
      |                      ^~~~
a.cc:27:20: error: reference to 'hash' is ambiguous
   27 |                 if(hash[v]==0){
      |                    ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:7:22: note:                 'int hash [300005]'
    7 | int n,m,dist[300005],hash[300005]={};
      |                      ^~~~
a.cc:28:25: error: reference to 'hash' is ambiguous
   28 |                         hash[v]=1;
      |                         ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:7:22: note:                 'int hash [300005]'
    7 | int n,m,dist[300005],hash[300005]={};
      |                      ^~~~
a.cc: In function 'int main()':
a.cc:51:12: error: reference to 'hash' is ambiguous
   51 |         if(hash[col[i][j]]!=i){
      |            ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:7:22: note:                 'int hash [300005]'
    7 | int n,m,dist[300005],hash[300005]={};
      |                      ^~~~