Language: C++

#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<cstring>
#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:16:9: error: reference to 'hash' is ambiguous
   16 |         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/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/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:11:22: note:                 'int hash [300005]'
   11 | int n,m,dist[300005],hash[300005]={};
      |                      ^~~~
a.cc:20:32: error: reference to 'hash' is ambiguous
   20 |         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:11:22: note:                 'int hash [300005]'
   11 | int n,m,dist[300005],hash[300005]={};
      |                      ^~~~
a.cc: In function 'void dij()':
a.cc:24:16: error: reference to 'hash' is ambiguous
   24 |         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:11:22: note:                 'int hash [300005]'
   11 | int n,m,dist[300005],hash[300005]={};
      |                      ^~~~
a.cc:24:30: error: reference to 'hash' is ambiguous
   24 |         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:11:22: note:                 'int hash [300005]'
   11 | int n,m,dist[300005],hash[300005]={};
      |                      ^~~~
a.cc:31:20: error: reference to 'hash' is ambiguous
   31 |                 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:11:22: note:                 'int hash [300005]'
   11 | int n,m,dist[300005],hash[300005]={};
      |                      ^~~~
a.cc:32:25: error: reference to 'hash' is ambiguous
   32 |                         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:11:22: note:                 'int hash [300005]'
   11 | int n,m,dist[300005],hash[300005]={};
      |                      ^~~~
a.cc: In function 'int main()':
a.cc:55:12: error: reference to 'hash' is ambiguous
   55 |         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:11:22: note:                 'int hash [300005]'
   11 | int n,m,dist[300005],hash[300005]={};
      |                      ^~~~