Language: C++

#include <bits/stdc++.h>

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

constexpr int N_MAX = 1001;
constexpr ll INF = 1000000000000000000;

int n, m;
vector<tuple<int, int, ll> > g;
vector<tuple<ll, int> > v;
int main(void)
{
	cin >> n >> m;
	rep(i, n + 1) {
		v.push_back(make_tuple(INF, -1));
	}
	v[1] = 0;
	rep(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		g.push_back(make_tuple(a, b, (ll)-c));
	}
	rep(i, n) {
		rep(j, m) {
			int s = get<0>(g[j]), t = get<1>(g[j]);
			ll w = get<2>(g[j]);
			if(get<0>(v[t]) > get<0>(v[s]) + w) {
				v[t] = make_tuple(v[s] + w, s);
			}
		}
	}
	int now = n;
	while(now != -1) {
		int prev = get<1>(v[now]);
		if(get<0>(v[now]) > get<0>(v[prev]) + w) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << -v[n] << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:16: error: no match for 'operator=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::tuple<long long int, int> >, std::tuple<long long int, int> >::value_type' {aka 'std::tuple<long long int, int>'} and 'int')
   29 |         v[1] = 0;
      |                ^
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
                 from /usr/include/c++/14/string:68,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/tuple:2355:9: note: candidate: 'template<class _U1, class _U2> std::__enable_if_t<((bool)__assignable<const _U1&, const _U2&>()), std::tuple<_T1, _T2>&> std::tuple<_T1, _T2>::operator=(const std::tuple<_U1, _U2>&) [with _U2 = _U1; _T1 = long long int; _T2 = int]'
 2355 |         operator=(const tuple<_U1, _U2>& __in)
      |         ^~~~~~~~
/usr/include/c++/14/tuple:2355:9: note:   template argument deduction/substitution failed:
a.cc:29:16: note:   mismatched types 'const std::tuple<_T1, _T2>' and 'int'
   29 |         v[1] = 0;
      |                ^
/usr/include/c++/14/tuple:2365:9: note: candidate: 'template<class _U1, class _U2> std::__enable_if_t<((bool)__assignable<_U1, _U2>()), std::tuple<_T1, _T2>&> std::tuple<_T1, _T2>::operator=(std::tuple<_U1, _U2>&&) [with _U2 = _U1; _T1 = long long int; _T2 = int]'
 2365 |         operator=(tuple<_U1, _U2>&& __in)
      |         ^~~~~~~~
/usr/include/c++/14/tuple:2365:9: note:   template argument deduction/substitution failed:
a.cc:29:16: note:   mismatched types 'std::tuple<_T1, _T2>' and 'int'
   29 |         v[1] = 0;
      |                ^
/usr/include/c++/14/tuple:2375:9: note: candidate: 'template<class _U1, class _U2> std::__enable_if_t<((bool)__assignable<const _U1&, const _U2&>()), std::tuple<_T1, _T2>&> std::tuple<_T1, _T2>::operator=(const std::pair<_U1, _U2>&) [with _U2 = _U1; _T1 = long long int; _T2 = int]'
 2375 |         operator=(const pair<_U1, _U2>& __in)
      |         ^~~~~~~~
/usr/include/c++/14/tuple:2375:9: note:   template argument deduction/substitution failed:
a.cc:29:16: note:   mismatched types 'const std::pair<_T1, _T2>' and 'int'
   29 |         v[1] = 0;
      |                ^
/usr/include/c++/14/tuple:2386:9: note: candidate: 'template<class _U1, class _U2> std::__enable_if_t<((bool)__assignable<_U1, _U2>()), std::tuple<_T1, _T2>&> std::tuple<_T1, _T2>::operator=(std::pair<_U1, _U2>&&) [with _U2 = _U1; _T1 = long long int; _T2 = int]'
 2386 |         operator=(pair<_U1, _U2>&& __in)
      |         ^~~~~~~~
/usr/include/c++/14/tuple:2386:9: note:   template argument deduction/substitution failed:
a.cc:29:16: note:   mismatched types 'std::pair<_T1, _T2>' and 'int'
   29 |         v[1] = 0;
      |                ^
/usr/include/c++/14/tuple:2332:7: note: candidate: 'std::tuple<_T1, _T2>& std::tuple<_T1, _T2>::operator=(std::__conditional_t<((bool)__assignable<const _T1&, const _T2&>()), const std::tuple<_T1, _T2>&, const std::__nonesuch&>) [with _T1 = long long int; _T2 = int; std::__conditional_t<((bool)__assignable<const _T1&, const _T2&>()), const std::tuple<_T1, _T2>&, const std::__nonesuch&> = const std::tuple<long long int, int>&]'
 2332 |       operator=(__conditional_t<__assignable<const _T1&, const _T2&>(),
      |       ^~~~~~~~
/usr/include/c++/14/tuple:2334:52: note:   no known conversion for argument 1 from 'int' to 'std::__conditional_t<true, const std::tuple<long long int, int>&, const std::__nonesuch&>' {aka 'const std::tuple<long long int, int>&'}
 2332 |       operator=(__conditional_t<__assignable<const _T1&, const _T2&>(),
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 2333 |                                 const tuple&,
      |                                 ~~~~~~~~~~~~~       
 2334 |                                 const __nonesuch&> __in)
      |                                 ~~~~~~~~~~~~~~~~~~~^~~~
/usr/include/c++/14/tuple:2343:7: note: candidate: 'std::tuple<_T1, _T2>& std::tuple<_T1, _T2>::operator=(std::__conditional_t<((bool)__assignable<_T1, _T2>()), std::tuple<_T1, _T2>&&, std::__nonesuch&&>) [with _T1 = long long int; _T2 = int; std::__conditional_t<((bool)__assignable<_T1, _T2>()), std::tuple<_T1, _T2>&&, std::__nonesuch&&> = std::tuple<long long int, int>&&]'
 2343 |       operator=(__conditional_t<__assignable<_T1, _T2>(),
      |       ^~~~~~~~
/usr/include/c++/14/tuple:2345:47: note:   no known conversion for argument 1 from 'int' to 'std::__conditional_t<true, std::tuple<long long int, int>&&, std::__nonesuch&&>' {aka 'std::tuple<long long int, int>&&'}
 2343 |       operator=(__conditional_t<__assignable<_T1, _T2>(),
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 2344 |                                 tuple&&,
      |                                 ~~~~~~~~       
 2345 |                                 __nonesuch&&> __in)
      |                                 ~~~~~~~~~~~~~~^~~~
a.cc:40:56: error: no match for 'operator+' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::tuple<long long int, int> >, std::tuple<long long int, int> >::value_type' {aka 'std::tuple<long long int, int>'} and 'll' {aka 'long long int'})
   40 |                                 v[t] = make_tuple(v[s] + w, s);
In file included from /usr/include/c++/14/bits/stl_algobase.h:67,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_iterator.h:627:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename reverse_iterator<_Iterator>::difference_type, const reverse_iterator<_Iterator>&)'
  627 |     operator+(typename reverse_iterator<_Iterator>::difference_type __n,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:627:5: note:   template argument deduction/substitution failed:
a.cc:40:58: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'll' {aka 'long long int'}
   40 |                                 v[t] = make_tuple(v[s] + w, s);
      |                                                          ^
/usr/include/c++/14/bits/stl_iterator.h:1798:5: note: candidate: 'template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename move_iterator<_IteratorL>::difference_type, const move_iterator<_IteratorL>&)'
 1798 |     operator+(typename move_iterator<_Iterator>::difference_type __n,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1798:5: note:   template argument deduction/substitution failed:
a.cc:40:58: note:   mismatched types 'const std::move_iterator<_IteratorL>' and 'll' {aka 'long long int'}
   40 |                                 v[t] = make_tuple(v[s] + w, s);
      |                                                          ^
In file included from /usr/include/c++/14/string:54:
/usr/include/c++/14/bits/basic_string.h:3598:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3598 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3598:5: note:   template argument deduction/substitution failed:
a.cc:40:58: note:   '__gnu_cxx::__alloc_traits<std::allocator<std::tuple<long long int, int> >, std::tuple<long long int, int> >::value_type' {aka 'std::tuple<long long int, int>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   40 |                                 v[t] = make_tuple(v[s] + w, s);
      |                                                          ^
/usr/include/c++/14/bits/basic_string.h:3616:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3616 |     operator+(const _CharT* __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3616:5: note:   template argument deduction/substitution failed:
a.cc:40:58: note:   mismatched types 'const _CharT*' and 'std::tuple<long long int, int>'
   40 |                                 v[t] = make_tuple(v[s] + w, s);
      |                                                          ^
/usr/include/c++/14/bits/basic_string.h:3635:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3635 |     operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3635:5: note:   template argument deduction/substitution failed:
a.cc:40:58: note:   mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'll' {aka 'long long int'}
   40 |                                 v[t] = make_tuple(v[s] + w, s);
      |                                                          ^
/usr/include/c++/14/bits/basic_string.h:3652:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
 3652 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3652:5: note:   template argument deduction/substitution failed:
a.cc:40:58: note:   '__gnu_cxx::__alloc_traits<std::allocator<std::tuple<long long int, int> >, std::tuple<long long int, int> >::value_type' {aka 'std::tuple<long long int, int>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   40 |                                 v[t] = make_tuple(v[s] + w, s);
      |                                                          ^
/usr/include/c++/14/bits/basic