Language: C++

#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <iomanip>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;

#define ll long long
#define pii pair<int,int>
/**==Info==
*Program:1
*Problem:すぬけ君の地下鉄旅行 / Snuke's Subway Trip
*Date:2018-7-14
*Algorithm:BFS Tourist's
*Stats:Unknown*/

bool debug=false;



template<typename T> struct undispose_queue{
	vector<T> v;
	int s;
	
	undispose_queue(){
		s=0;
		v.clear();
	}
	
	void push(T value){
		v.push_back(value);
	}
	void pop(){
		s++;
	}
	
	T front(){
		return v[s];
	}
	
	void clear(){
		v.clear();
		s=0;
	}
	
	bool empty(){
		return s==v.size();
	}
	
	int size(){
		return v.size()-s;
	}
	
	vector<T> getData(){
		return v;
	}
};

int FUCK=2e6+1;
int n,m;

map<int,vector<int>> nei[FUCK];

int col[FUCK];

set<int> cols;
vector<int> on[FUCK];

vector<int> nnei[FUCK];

int dis[FUCK];

int main(int argc,char* argv[]){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		a--;b--;
		nei[a][c].push_back(b);
		nei[b][c].push_back(a);
		on[c].push_back(a);
		on[c].push_back(b);
		cols.insert(c);
	}
	
	if(debug)cout<<"ok"<<endl;
	
	memset(col,-1,sizeof(col));
	
	int stpos=n;
	
	for(set<int>::iterator it=cols.begin();it!=cols.end();it++){
		int thscol=*it;
		if(debug)cout<<thscol<<endl;
		
		for(int i=0;i<on[thscol].size();i++){
			int thspos=on[thscol][i];
			if(col[thspos]==thscol){
				continue; //In the same block
			}
			
			undispose_queue<int> uq;
			col[thspos]=thscol;
			uq.push(thspos);
			
			while(!uq.empty()){
				
				int last=uq.front();
				uq.pop();
				
				for(int j=0;j<nei[last][thscol].size();j++){
					int nxtpos=nei[last][thscol][j];
					if(col[nxtpos]!=thscol){
						col[nxtpos]=thscol;
						uq.push(nxtpos);
					}
				}
			}
			
			vector<int> v=uq.getData();
			
			for(int j=0;j<v.size();j++){
				nnei[v[j]].push_back(stpos);
				nnei[stpos].push_back(v[j]);
				
				if(debug)cout<<"connected "<<v[j]<<" and "<<stpos<<endl;
			}
			
			stpos++;
		}
		
	}
	
	
	if(debug)cout<<"bfs"<<endl;
	
	queue<int> q;
	
	fill(dis,dis+2*n,-2);
	dis[0]=0;
	q.push(0);
	while(!q.empty()){
		int last=q.front();
		q.pop();
		
		for(int i=0;i<nnei[last].size();i++){
			if(dis[nnei[last][i]]==-2){
				dis[nnei[last][i]]=dis[last]+1;
				q.push(nnei[last][i]);
			}
		}
	}
	
	cout<<dis[n-1]/2;
	return 0;
}



Compiler output:
a.cc:79:26: error: size of array 'nei' is not an integral constant-expression
   79 | map<int,vector<int>> nei[FUCK];
      |                          ^~~~
a.cc:81:9: error: size of array 'col' is not an integral constant-expression
   81 | int col[FUCK];
      |         ^~~~
a.cc:84:16: error: size of array 'on' is not an integral constant-expression
   84 | vector<int> on[FUCK];
      |                ^~~~
a.cc:86:18: error: size of array 'nnei' is not an integral constant-expression
   86 | vector<int> nnei[FUCK];
      |                  ^~~~
a.cc:88:9: error: size of array 'dis' is not an integral constant-expression
   88 | int dis[FUCK];
      |         ^~~~