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>
#define CLR(x) memset(x,0,sizeof x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 1000000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
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:69:13: error: expected unqualified-id before numeric constant
   69 | #define INF 1000000000
      |             ^~~~~~~~~~
a.cc:158:11: note: in expansion of macro 'INF'
  158 | const int INF=1e9+7;
      |           ^~~