Language: C++

#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define substr(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
map<pair<ll,ll>,ll>MP;
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=2211111;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});E[to].pb({from,cost});}
  void dijkstra(ll s){
    priority_queue<pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> > >que;
    init();
    d[s] = 0;
    que.push(pair<ll,ll>(0,s));
    while(!que.empty()){
      pair<ll,ll> p=que.top();que.pop();
      ll v = p.second;
      if(d[v]<p.first)continue;
      for(int j=0;j<E[v].size();j++){
	Edge t = E[v][j];
	if(d[t.to]>d[v]+t.cost){
	  d[t.to]=d[v]+t.cost;
	  que.push(pair<ll,ll>(d[t.to],t.to));
	}
      }
    }
  }
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  int cnt=1;
  Graph G(2211110);
  for(int i=0;i<m;i++){
    ll a,b,c;cin>>a>>b>>c;
    if(MP[mp(a,-1)]==0)MP[mp(a,-1)]=cnt++;
    if(MP[mp(b,-1)]==0)MP[mp(b,-1)]=cnt++;
    if(MP[mp(a,c)]==0)MP[mp(a,c)]=cnt++;
    if(MP[mp(b,c)]==0)MP[mp(b,c)]=cnt++;
    G.add_edge(MP[mp(a,-1)],MP[mp(a,c)],1);
    G.add_edge(MP[mp(b,-1)],MP[mp(b,c)],1);
    G.add_edge(MP[mp(a,c)],MP[mp(b,c)],0);
  }
  if(MP[(1,-1)]==0){
    cout<<-1<<endl;
    return 0;
  }
  G.dijkstra(MP[mp(1,-1)]);
  if(G.d[MP[mp(n,-1)]]==llINF)cout<<-1<<endl;
  else cout<<G.d[MP[mp(n,-1)]]/2<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:60:8: error: no match for 'operator[]' (operand types are 'std::map<std::pair<long long int, long long int>, long long int>' and 'int')
   60 |   if(MP[(1,-1)]==0){
      |        ^
In file included from /usr/include/c++/14/map:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<long long int, long long int>; _Tp = long long int; _Compare = std::less<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, long long int> >; mapped_type = long long int; key_type = std::pair<long long int, long long int>]'
  504 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:504:34: note:   no known conversion for argument 1 from 'int' to 'const std::map<std::pair<long long int, long long int>, long long int>::key_type&' {aka 'const std::pair<long long int, long long int>&'}
  504 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = std::pair<long long int, long long int>; _Tp = long long int; _Compare = std::less<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, long long int> >; mapped_type = long long int; key_type = std::pair<long long int, long long int>]'
  524 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:524:29: note:   no known conversion for argument 1 from 'int' to 'std::map<std::pair<long long int, long long int>, long long int>::key_type&&' {aka 'std::pair<long long int, long long int>&&'}
  524 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~