Language: C++

#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>

using namespace std;

constexpr int MAX_N = 2525;
 constexpr LL INF = 1e15;
 
 vector<int> go[MAX_N];
 vector<int> back[MAX_N];
 vector<bool> go_state(MAX_N, false);
 vector<bool> back_state(MAX_N, false);
 
 void dfs(int v, vector<int> way[], vector<bool> &state) {
     if (state[v])return;
     state[v] = true;
     for (auto to: way[v]) {
         dfs(to, way, state);
     }
 }
 
 
 int main() {
 
     int N, M, P;
     cin >> N >> M >> P;
 
     vector<int> A(M), B(M), C(M);
     vector<tuple<int, int, int>> edges(M);
     for (int i = 0; i < M; i++) {
         cin >> A[i] >> B[i] >> C[i];
         A[i]--, B[i]--;
         C[i] -= P;
         edges[i] = make_tuple(A[i], B[i], C[i]);
         go[A[i]].push_back(B[i]);
         back[B[i]].push_back(A[i]);
     }
 
     dfs(0, go, go_state);
     dfs(N - 1, back, back_state);
 
     vector<bool> sects(MAX_N, false);
     for (int i = 0; i < N; i++) sects[i] = go_state[i] & back_state[i];
 
     vector<LL> dist(N, -INF);
     dist[0] = 0;
     for (int i = 0; i < N; i++) {
         for (auto &e: edges) {
             int a, b, c;
             tie(a, b, c) = e;
             if (dist[a] != -INF) {
                 dist[b] = max(dist[b], dist[a] + c);
             }
         }
     }
 
     auto cp = dist;
     for (int i = 0; i < N; i++) {
         for (auto &e: edges) {
             int a, b, c;
             tie(a, b, c) = e;
             if (dist[a] != -INF) {
                 dist[b] = max(dist[b], dist[a] + c);
             }
         }
     }
 
     for (int i = 0; i < N; i++) {
         if (sects[i] && (cp[i] != dist[i])) {
             cout << -1 << endl;
             return 0;
         }
     }
 
     cout << max(0LL, dist[N - 1]) << endl;
 
 }
 

Compiler output:
a.cc:18:12: error: 'LL' does not name a type
   18 |  constexpr LL INF = 1e15;
      |            ^~
a.cc: In function 'int main()':
a.cc:56:13: error: 'LL' was not declared in this scope
   56 |      vector<LL> dist(N, -INF);
      |             ^~
a.cc:56:15: error: template argument 1 is invalid
   56 |      vector<LL> dist(N, -INF);
      |               ^
a.cc:56:15: error: template argument 2 is invalid
a.cc:56:26: error: 'INF' was not declared in this scope
   56 |      vector<LL> dist(N, -INF);
      |                          ^~~
a.cc:56:29: error: expression list treated as compound expression in initializer [-fpermissive]
   56 |      vector<LL> dist(N, -INF);
      |                             ^
a.cc:57:10: error: invalid types 'int[int]' for array subscript
   57 |      dist[0] = 0;
      |          ^
a.cc:62:22: error: invalid types 'int[int]' for array subscript
   62 |              if (dist[a] != -INF) {
      |                      ^
a.cc:63:22: error: invalid types 'int[int]' for array subscript
   63 |                  dist[b] = max(dist[b], dist[a] + c);
      |                      ^
a.cc:63:36: error: invalid types 'int[int]' for array subscript
   63 |                  dist[b] = max(dist[b], dist[a] + c);
      |                                    ^
a.cc:63:45: error: invalid types 'int[int]' for array subscript
   63 |                  dist[b] = max(dist[b], dist[a] + c);
      |                                             ^
a.cc:73:22: error: invalid types 'int[int]' for array subscript
   73 |              if (dist[a] != -INF) {
      |                      ^
a.cc:74:22: error: invalid types 'int[int]' for array subscript
   74 |                  dist[b] = max(dist[b], dist[a] + c);
      |                      ^
a.cc:74:36: error: invalid types 'int[int]' for array subscript
   74 |                  dist[b] = max(dist[b], dist[a] + c);
      |                                    ^
a.cc:74:45: error: invalid types 'int[int]' for array subscript
   74 |                  dist[b] = max(dist[b], dist[a] + c);
      |                                             ^
a.cc:80:29: error: invalid types 'int[int]' for array subscript
   80 |          if (sects[i] && (cp[i] != dist[i])) {
      |                             ^
a.cc:80:40: error: invalid types 'int[int]' for array subscript
   80 |          if (sects[i] && (cp[i] != dist[i])) {
      |                                        ^
a.cc:86:27: error: invalid types 'int[int]' for array subscript
   86 |      cout << max(0LL, dist[N - 1]) << endl;
      |                           ^