Language: C++

//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
const int INF=1e9+7;

struct st{int p,b,c;};

bool operator < (const st &a,const st &b){return a.c>b.c;}

int n,m;
vector<int> g[100005];
map<int,int> d[100005];
map<int,vector<int> > ve[100005];
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		u--;v--;
		ve[u][w].push_back(v);
		ve[v][w].push_back(u);
		g[u].push_back(w);
		g[v].push_back(w);
	}
	priority_queue<st> pq;
	pq.push((st){0,0,0});
	d[0][0]=0;
	while(!pq.empty()){
		st p=pq.top();
		pq.pop();
		if(d[p.p][p.b]!=p.c) continue;
		if(d[p.p].find(0)==d[p.p].end()||d[p.p][0]>p.c){
			d[p.p][0]=p.c;
			pq.push((st){p.p,0,p.c});
		}
		if(p.b==0){
			for(int i=0;i<g[p.p].size();i++){
				int v=g[p.p][i];
				if(d[p.p].find(v)==d[p.p].end()||d[p.p][v]>p.c+1){
					d[p.p][v]=p.c+1;
					pq.push((st){p.p,v,p.c+1});
				}
			}
			continue;
		}
		for(int i=0;i<ve[p.p][p.b].size();i++){
			int v=ve[p.p][p.b][i];
			if(d[v].find(p.b)==d[v].end() || d[v][p.b]>p.c){
				d[v][p.b]=p.c;
				pq.push((st){v,p.b,p.c});
			}
		}
	}
	int ans=INF;
	for(map<int,int>::iterator it=d[n-1].begin();it!=d[n-1].end();it++) ans=min(ans,(it->second));
	if(ans==INF)
	puts("-1");
	else printf("%d\n",ans);
	printf("%d\n",ans);
	//system("pause");
	return 0;
}

Compiler output:
a.cc:66:1: error: 'vector' does not name a type
   66 | vector<int> g[100005];
      | ^~~~~~
a.cc:67:1: error: 'map' does not name a type
   67 | map<int,int> d[100005];
      | ^~~
a.cc:68:1: error: 'map' does not name a type
   68 | map<int,vector<int> > ve[100005];
      | ^~~
a.cc: In function 'int main()':
a.cc:77:17: error: 've' was not declared in this scope; did you mean 'v'?
   77 |                 ve[u][w].push_back(v);
      |                 ^~
      |                 v
a.cc:79:17: error: 'g' was not declared in this scope
   79 |                 g[u].push_back(w);
      |                 ^
a.cc:82:9: error: 'priority_queue' was not declared in this scope; did you mean 'std::priority_queue'?
   82 |         priority_queue<st> pq;
      |         ^~~~~~~~~~~~~~
      |         std::priority_queue
In file included from /usr/include/c++/14/queue:66,
                 from a.cc:45:
/usr/include/c++/14/bits/stl_queue.h:496:11: note: 'std::priority_queue' declared here
  496 |     class priority_queue
      |           ^~~~~~~~~~~~~~
a.cc:82:26: error: expected primary-expression before '>' token
   82 |         priority_queue<st> pq;
      |                          ^
a.cc:82:28: error: 'pq' was not declared in this scope
   82 |         priority_queue<st> pq;
      |                            ^~
a.cc:84:9: error: 'd' was not declared in this scope
   84 |         d[0][0]=0;
      |         ^
a.cc:94:39: error: 'g' was not declared in this scope
   94 |                         for(int i=0;i<g[p.p].size();i++){
      |                                       ^
a.cc:103:31: error: 've' was not declared in this scope
  103 |                 for(int i=0;i<ve[p.p][p.b].size();i++){
      |                               ^~
a.cc:112:13: error: 'map' was not declared in this scope
  112 |         for(map<int,int>::iterator it=d[n-1].begin();it!=d[n-1].end();it++) ans=min(ans,(it->second));
      |             ^~~
a.cc:112:13: note: suggested alternatives:
In file included from /usr/include/c++/14/map:63,
                 from a.cc:40:
/usr/include/c++/14/bits/stl_map.h:102:11: note:   'std::map'
  102 |     class map
      |           ^~~
/usr/include/c++/14/map:89:13: note:   'std::pmr::map'
   89 |       using map
      |             ^~~
a.cc:112:17: error: expected primary-expression before 'int'
  112 |         for(map<int,int>::iterator it=d[n-1].begin();it!=d[n-1].end();it++) ans=min(ans,(it->second));
      |                 ^~~
a.cc:112:54: error: 'it' was not declared in this scope; did you mean 'st'?
  112 |         for(map<int,int>::iterator it=d[n-1].begin();it!=d[n-1].end();it++) ans=min(ans,(it->second));
      |                                                      ^~
      |                                                      st
a.cc:112:81: error: 'min' was not declared in this scope; did you mean 'std::min'?
  112 |         for(map<int,int>::iterator it=d[n-1].begin();it!=d[n-1].end();it++) ans=min(ans,(it->second));
      |                                                                                 ^~~
      |                                                                                 std::min
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:7:
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~