Language: C++

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define u64 unsigned long long
#define u32 unsigned int
#define reg register
#define Raed Read
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define rep(a,b,c) for(reg int a=(b),a##_end_=(c); a<=a##_end_; ++a)
#define ret(a,b,c) for(reg int a=(b),a##_end_=(c); a<a##_end_; ++a)
#define drep(a,b,c) for(reg int a=(b),a##_end_=(c); a>=a##_end_; --a)
#define erep(i,G,x) for(reg int i=(G).Head[x]; i; i=(G).Nxt[i])

inline int Read() {
	int res = 0, f = 1;
	char c;
	while (c = getchar(), c < 48 || c > 57)if (c == '-')f = 0;
	do res = (res << 3) + (res << 1) + (c ^ 48);
	while (c = getchar(), c >= 48 && c <= 57);
	return f ? res : -res;
}

template<class T>inline bool Min(T &a, T const&b) {
	return a > b ? a = b, 1 : 0;
}
template<class T>inline bool Max(T &a, T const&b) {
	return a < b ? a = b, 1 : 0;
}

const int N = 1e5+5,M = 2e5 + 5,mod = 99999997;

bool MOP1;

struct Link_list {
	int Tot,Head[N],Nxt[M<<1],to[M<<1],cost[M<<1];
	inline clear(void) {
		memset(Head,0,sizeof Head),Tot=0;
	}
	inline void AddEdge(int a,int b,int c) {
		to[++Tot]=b,cost[Tot]=c,Nxt[Tot]=Head[a],Head[a]=Tot;
	}
} G,E;

int n,m,p,vis1[N],vis2[N],vis[N],Q[N];

int d[N],v[N],c[N];

bool spfa() {
	queue<int> q;
	for (int i = 1; i <= n; i++) {
		if(!vis[i])continue;
		q.push(i);
		d[i] = 0,v[i] = 1;
	}
	memset(c, 0, sizeof(c));
	while (q.size()) {
		int x = q.front();
		q.pop();
		v[x] = 0;
		for (int i = G.Head[x]; i; i = G.Nxt[i]) {
			int y = G.to[i];
			if(!vis[y])continue;
			if (d[y] > d[x] + G.cost[i]) {
				d[y] = d[x] + G.cost[i];
				if (++c[y] > n) return 1;
				if (!v[y])q.push(y),v[y] = 1;
			}
		}
	}
	return 0;
}

bool MOP2;

inline void _main(void) {
	n=Raed(),m=Raed(),p=Raed();
	rep(i,1,m) {
		int x=Raed(),y=Raed(),z=Read();
		G.AddEdge(x,y,p-z);
		E.AddEdge(y,x,p-z);
	}
	int L=0,R=0;
	Q[++R]=n,vis1[n]=1;
	while(L<R) {
		int x=Q[++L];
		erep(i,E,x) {
			int y=E.to[i];
			if(vis1[y])continue;
			vis1[y]=1,Q[++R]=y;
		}
	}
	L=0,R=0;
	Q[++R]=1,vis2[1]=1;
	while(L<R) {
		int x=Q[++L];
		erep(i,G,x) {
			int y=G.to[i];
			if(vis2[y])continue;
			vis2[y]=1,Q[++R]=y;
		}
	}
	rep(i,1,n)if(vis1[i]&&vis2[i])vis[i]=1;
//	debug(vis[3]);
	if(!vis[1]) {
		puts("-1");
		return;
	}
	if(spfa()) {
		puts("-1");
		return;
	}
	printf("%d",-d[n]);
}

signed main() {
#define offline1
#ifdef offline
	freopen("truck.in", "r", stdin);
	freopen("truck.out", "w", stdout);
	_main();
	fclose(stdin);
	fclose(stdout);
#else
	_main();
#endif
	return 0;
}

Compiler output:
a.cc:38:16: error: ISO C++ forbids declaration of 'clear' with no type [-fpermissive]
   38 |         inline clear(void) {
      |                ^~~~~
a.cc: In member function 'int Link_list::clear()':
a.cc:40:9: warning: no return statement in function returning non-void [-Wreturn-type]
   40 |         }
      |         ^
a.cc: In function 'void _main()':
a.cc:79:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   79 |         rep(i,1,m) {
      |             ^
a.cc:11:32: note: in definition of macro 'rep'
   11 | #define rep(a,b,c) for(reg int a=(b),a##_end_=(c); a<=a##_end_; ++a)
      |                                ^
a.cc:79:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   79 |         rep(i,1,m) {
      |             ^
a.cc:11:38: note: in definition of macro 'rep'
   11 | #define rep(a,b,c) for(reg int a=(b),a##_end_=(c); a<=a##_end_; ++a)
      |                                      ^
a.cc:88:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   88 |                 erep(i,E,x) {
      |                      ^
a.cc:14:33: note: in definition of macro 'erep'
   14 | #define erep(i,G,x) for(reg int i=(G).Head[x]; i; i=(G).Nxt[i])
      |                                 ^
a.cc:98:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   98 |                 erep(i,G,x) {
      |                      ^
a.cc:14:33: note: in definition of macro 'erep'
   14 | #define erep(i,G,x) for(reg int i=(G).Head[x]; i; i=(G).Nxt[i])
      |                                 ^
a.cc:104:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
  104 |         rep(i,1,n)if(vis1[i]&&vis2[i])vis[i]=1;
      |             ^
a.cc:11:32: note: in definition of macro 'rep'
   11 | #define rep(a,b,c) for(reg int a=(b),a##_end_=(c); a<=a##_end_; ++a)
      |                                ^
a.cc:104:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
  104 |         rep(i,1,n)if(vis1[i]&&vis2[i])vis[i]=1;
      |             ^
a.cc:11:38: note: in definition of macro 'rep'
   11 | #define rep(a,b,c) for(reg int a=(b),a##_end_=(c); a<=a##_end_; ++a)
      |                                      ^