Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
// typedef tuple<int, int, int> TUPLE;
typedef tuple<int, int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;
// template<typename T> using Graph = vector<vector<T>>;

struct edge {
    int to, id;
    edge(){}
    edge(int _to, int _id) : to(_to), id(_id) {}
};
typedef vector<vector<edge>> Graph;

int dijkstra(const Graph& G, int s, int g) {
    int N = G.size();
    priority_queue<TUPLE, vector<TUPLE>, greater<TUPLE>> pq;   // {cost, id, v, pre}
    set<TUPLE> st;
    vi d(N, inf);
    d[s] = 0;
    pq.push(make_tuple(0, -1, s, -1));
    st.insert(make_tuple(0, -1, s, -1));


    while (!pq.empty()) {
        int cost, id, v, pre;
        tie(cost, id, v, pre) = pq.top(); pq.pop();
        if (v == g) break;
        if (d[v] < cost) continue;
        for (const auto& e : G[v]) {
            if (e.to == pre) continue;
            if (d[e.to] >= d[v] + (e.id != id)) {
                d[e.to] = d[v] + (e.id != id);
                if (st.count(make_tuple(d[e.to], e.id, e.to))) continue;
                pq.push(make_tuple(d[e.to], e.id, e.to, v));
                st.insert(make_tuple(d[e.to], e.id, e.to));
            }
        }
    }
    return d[g];
}
signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int N, M;
    cin >> N >> M;
    Graph G(N);
    rep(i, M) {
        int p, q, c;
        cin >> p >> q >> c;
        p--, q--;
        G[p].emplace_back(q, c);
        G[q].emplace_back(p, c);
    }

    int ans = dijkstra(G, 0, N - 1);
    if (ans == inf) ans = -1;
    cout << ans << endl;

}


Compiler output:
a.cc: In function 'long long int dijkstra(const Graph&, long long int, long long int)':
a.cc:53:29: error: no matching function for call to 'std::set<std::tuple<long long int, long long int, long long int, long long int> >::count(std::tuple<long long int, long long int, long long int>)'
   53 |                 if (st.count(make_tuple(d[e.to], e.id, e.to))) continue;
      |                     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/set:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:158,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_set.h:756:9: note: candidate: 'template<class _Kt> decltype (((const std::set<_Key, _Compare, _Alloc>*)this)->std::set<_Key, _Compare, _Alloc>::_M_t._M_count_tr(__x)) std::set<_Key, _Compare, _Alloc>::count(const _Kt&) const [with _Key = std::tuple<long long int, long long int, long long int, long long int>; _Compare = std::less<std::tuple<long long int, long long int, long long int, long long int> >; _Alloc = std::allocator<std::tuple<long long int, long long int, long long int, long long int> >]'
  756 |         count(const _Kt& __x) const
      |         ^~~~~
/usr/include/c++/14/bits/stl_set.h:756:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_set.h: In substitution of 'template<class _Kt> decltype (((const std::set<std::tuple<long long int, long long int, long long int, long long int> >*)this)->std::set<std::tuple<long long int, long long int, long long int, long long int> >::_M_t.std::_Rb_tree<std::tuple<long long int, long long int, long long int, long long int>, std::tuple<long long int, long long int, long long int, long long int>, std::_Identity<std::tuple<long long int, long long int, long long int, long long int> >, std::less<std::tuple<long long int, long long int, long long int, long long int> >, std::allocator<std::tuple<long long int, long long int, long long int, long long int> > >::_M_count_tr<_Kt, _Req>(__x)) std::set<std::tuple<long long int, long long int, long long int, long long int> >::count(const _Kt&) const [with _Kt = std::tuple<long long int, long long int, long long int>]':
a.cc:53:29:   required from here
   53 |                 if (st.count(make_tuple(d[e.to], e.id, e.to))) continue;
      |                     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:757:37: error: no matching function for call to 'std::_Rb_tree<std::tuple<long long int, long long int, long long int, long long int>, std::tuple<long long int, long long int, long long int, long long int>, std::_Identity<std::tuple<long long int, long long int, long long int, long long int> >, std::less<std::tuple<long long int, long long int, long long int, long long int> >, std::allocator<std::tuple<long long int, long long int, long long int, long long int> > >::_M_count_tr(const std::tuple<long long int, long long int, long long int>&) const'
  757 |         -> decltype(_M_t._M_count_tr(__x))
      |                     ~~~~~~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/14/map:62,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152:
/usr/include/c++/14/bits/stl_tree.h:1311:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_count_tr(const _Kt&) const [with _Req = _Kt; _Key = std::tuple<long long int, long long int, long long int, long long int>; _Val = std::tuple<long long int, long long int, long long int, long long int>; _KeyOfValue = std::_Identity<std::tuple<long long int, long long int, long long int, long long int> >; _Compare = std::less<std::tuple<long long int, long long int, long long int, long long int> >; _Alloc = std::allocator<std::tuple<long long int, long long int, long long int, long long int> >]'
 1311 |         _M_count_tr(const _Kt& __k) const
      |         ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1311:9: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/14/string:49,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/stl_function.h: In substitution of 'template<class _Func, class _SfinaeType> using std::__has_is_transparent_t = typename std::__has_is_transparent<_Func, _SfinaeType>::type [with _Func = std::less<std::tuple<long long int, long long int, long long int, long long int> >; _SfinaeType = std::tuple<long long int, long long int, long long int>]':
/usr/include/c++/14/bits/stl_tree.h:1309:9:   required by substitution of 'template<class _Kt> decltype (((const std::set<std::tuple<long long int, long long int, long long int, long long int> >*)this)->std::set<std::tuple<long long int, long long int, long long int, long long int> >::_M_t.std::_Rb_tree<std::tuple<long long int, long long int, long long int, long long int>, std::tuple<long long int, long long int, long long int, long long int>, std::_Identity<std::tuple<long long int, long long int, long long int, long long int> >, std::less<std::tuple<long long int, long long int, long long int, long long int> >, std::allocator<std::tuple<long long int, long long int, long long int, long long int> > >::_M_count_tr<_Kt, _Req>(__x)) std::set<std::tuple<long long int, long long int, long long int, long long int> >::count(const _Kt&) const [with _Kt = std::tuple<long long int, long long int, long long int>]'
 1309 |                typename _Req = __has_is_transparent_t<_Compare, _Kt>>
      |                ^~~~~~~~
a.cc:53:29:   required from here
   53 |                 if (st.count(make_tuple(d[e.to], e.id, e.to))) continue;
      |                     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_function.h:1427:11: error: no type named 'type' in 'struct std::__has_is_transparent<std::less<std::tuple<long long int, long long int, long long int, long long int> >, std::tuple<long long int, long long int, long long int>, void>'
 1427 |     using __has_is_transparent_t
      |           ^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:750:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::count(const key_type&) const [with _Key = std::tuple<long long int, long long int, long long int, long long int>; _Compare = std::less<std::tuple<long long int, long long int, long long int, long long int> >; _Alloc = std::allocator<std::tuple<long long int, long long int, long long int, long long int> >; size_type = long unsigned int; key_type = std::tuple<long long int, long long int, long long int, long long int>]'
  750 |       count(const key_type& __x) const
      |       ^~~~~
/usr/include/c++/14/bits/stl_set.h:750:29: note:   no known conversion for argument 1 from 'std::tuple<long long int, long long int, long long int>' to 'const std::set<std::tuple<long long int, long long int, long long int, long long int> >::key_type&' {aka 'const std::tuple<long long int, long long int, long long int, long long int>&'}
  750 |       count(const key_type& __x) const
      |             ~~~~~~~~~~~~~~~~^~~
a.cc:55:26: error: no matching function for call to 'std::set<std::tuple<long long int, long long int, long long int, long long int> >::insert(std::tuple<long long int, long long int, long long int>)'
   55 |                 st.insert(make_tuple(d[e.to], e.id, e.to));
      |                 ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:568:9: note: candidate: 'template<class _InputIterator> void std::set<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _Key = std::tuple<long long int, long long int, long long int, long long int>; _Compare = std::less<std::tuple<long long int, long long int, long long int, long long int> >; _Alloc = std::allocator<std::tuple<long long int, long long int, long long int, long long int> >]'
  568 |         insert(_InputIterator __first, _InputIterator __last)
      |         ^~~~~~
/usr/include/c++/14/bits/stl_set.h:568:9: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_set.h:511:7: note: candidate: 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = std::tuple<long long int, long long int, long long int, long long int>; _Compare = std::less<std::tuple<long long int, long long int, long long int, long long int> >; _Alloc = std::allocator<std::tuple<long long int, long long int, long long int, long long int> >; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<std::tuple<long long int, long long int, long long int, long long int>, std::tuple<long long int, long long int, long long int, long long int>, std::_Identity<std::tuple<long long int, long long int, long long int, long long int> >, std::less<std::tuple<long long int, long long int, long long int, long long int> >, std::allocator<std::tuple<long long int, long long int, long long int, long long int> > >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<std::tuple<long long int, long long int, long long int, long long int> >; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<std::tuple<long long int, long long int, long long int, long long int> >, std::tuple<long long int, long long int, long long int, long long int> >::rebind<std::tuple<long long int, long long int, long long int, long long int> >; typename _Alloc::value_type = std::tuple<long long int, long long int, long long int, long long int>; value_type = std::tuple<long long int, long long int, long long int, long long int>]'
  511 |       insert(const value_type& __x)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:511:32: note:   no known conversion for argument 1 from 'std::tuple<long long int, long