Language: C++

#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())
inline void Fail(){
	printf("0");
	exit(0);
}
inline void Unique(vector<int>&v){
	sort(v.begin(),v.end());
	v.resize(unique(v.begin(),v.end())-v.begin());
}
inline int Get(vector<int>v,int x){
	return lower_bound(v.begin(),v.end(),x)-v.begin();
}

const int maxn=2000005;
int n,m,cnt,ans=INF;
vector<pii>edge[maxn];
vector<int>col[maxn],index[maxn];
int dist[maxn],a[maxn],b[maxn],c[maxn];

void Dijkstra(){
	priority_queue<pii,vector<pii>,greater<pii> >q;
	rep(i,maxn)dist[i]=INF; 
	dist[0]=0;
	q.push(mk(0,0));
	while(!q.empty()){
		pii x=q.top();q.pop();
		if(x.first!=dist[x.second])continue;
		rep(i,edge[x.second].size()){
			pii y=edge[x.second][i];
			if(dist[x.second]+y.second<dist[y.first]){
				dist[y.first]=dist[x.second]+y.second;
				q.push(mk(dist[y.first],y.first));
			}
		}
	}
}

int main(){
	scanf("%d%d",&n,&m);
	rep(i,m){
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
		a[i]--;b[i]--;
		col[a[i]].push_back(c[i]);
		col[b[i]].push_back(c[i]);
	}
	cnt=n;
	rep(i,n){
		Unique(col[i]);
		rep(j,col[i].size())index[i].push_back(cnt++);
	}
	rep(i,m){
		int x=index[a[i]][Get(col[a[i]],c[i])];
		int y=index[b[i]][Get(col[b[i]],c[i])];
		edge[x].push_back(make_pair(y,0));
		edge[y].push_back(make_pair(x,0));
	}
	rep(i,n){
		rep(j,index[i].size()){
			int x=index[i][j];
			edge[i].push_back(make_pair(x,1));
			edge[x].push_back(make_pair(i,0));
		}
	}
	Dijkstra();
	rep(i,index[n-1].size()){
		int x=index[n-1][i];
		ans=min(ans,dist[x]); 
	}
	printf("%d",(ans==INF)?-1:ans);
	return 0;
}

Compiler output:
a.cc:69:32: error: 'std::vector<int> index [2000005]' redeclared as different kind of entity
   69 | vector<int>col[maxn],index[maxn];
      |                                ^
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from a.cc:7:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'int main()':
a.cc:101:42: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  101 |                 rep(j,col[i].size())index[i].push_back(cnt++);
      |                                          ^
a.cc:104:28: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  104 |                 int x=index[a[i]][Get(col[a[i]],c[i])];
      |                            ^
a.cc:105:28: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  105 |                 int y=index[b[i]][Get(col[b[i]],c[i])];
      |                            ^
a.cc:110:28: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  110 |                 rep(j,index[i].size()){
      |                            ^
a.cc:46:36: note: in definition of macro 'rep'
   46 | #define rep(i,n) for(int (i)=0;(i)<n;i++)
      |                                    ^
a.cc:111:36: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  111 |                         int x=index[i][j];
      |                                    ^
a.cc:117:20: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  117 |         rep(i,index[n-1].size()){
      |                    ^
a.cc:46:36: note: in definition of macro 'rep'
   46 | #define rep(i,n) for(int (i)=0;(i)<n;i++)
      |                                    ^
a.cc:118:28: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
  118 |                 int x=index[n-1][i];
      |                            ^