Language: C++

#include <iostream>
#include<vector>
using namespace std;
struct data {
	long long to,val;
};
vector<data> v[5100],v1[5100];
long long a[5100],b[5100],h[5100],d[5100];
long long n,m,k,t[5100],r,e;
bool no=false;
void dfs(long long x,long long y)
{
	if(y==1)
	{
		for(long long i=0;i<v[x].size();i++)
		{ 
			data d;
			d.to=x;
			d.val=v[x][i].val;
			if(x==v[x][i].to)
			{
				v1[v[x][i].to].push_back(d);
				continue;	
			}
			v1[v[x][i].to].push_back(d);
			dfs(v[x][i].to,1);
		}
		return ;
	}
	else
	{
		for(long long i=0;i<v1[x].size();i++)
		{
			data d;
			d.to=v1[x][i].to;
			d.val=v1[x][i].val;
			if(x==v1[x][i].to)
			{
				v[v1[x][i].to].push_back(d);
				a[e]=x;
				b[e]=v1[x][i].to;
				h[e]=v1[x][i].val;
				e++;
				continue;
			}
			t[v1[x][i].to]++;
			v[x].push_back(d);
			a[e]=x;
			b[e]=v1[x][i].to;
			h[e]=v1[x][i].val;
			e++;
			dfs(v1[x][i].to,0);
		}
		return ;
	}
}
long long main(){
	cin>>n>>m>>k;
	for(long long i=0;i<m;i++)
	{
		cin>>a[i]>>b[i]>>h[i];
		h[i]-=k;
		if(h[i]<0)
			h[i]=0;
		data d;
		d.to=a[i];	
		d.val=h[i];
		v[b[i]].push_back(d);
	}
	dfs(n,1);
	for(long long i=0;i<n+2;i++)
	{
		d[i]=-99999999999;
		v[i].clear();
	}
	t[1]=1;
	dfs(1,0);
	for(long long i=1;i<=n;i++) 
		if(t[i]>0)
			r++;
	d[1]=0;
	for(long long i=1;i<=r+1;i++)	
	{
		for(long long o=0;o<e;o++)
		{
			if(d[a[o]]+h[o]>d[b[o]])	
			{
				d[b[o]]=d[a[o]]+h[o];
				if(r+1==i && d[b[o]]!=d[a[o]]+h[o])
				{
					no=true;
					break;
				}
			}
		}
		if(no==true)
			break;
	}
	if(no==true)
		cout<<"-1"<<endl;
	else
		cout<<d[n]<<endl;	
}

Compiler output:
a.cc:7:12: error: template argument 1 is invalid
    7 | vector<data> v[5100],v1[5100];
      |            ^
a.cc:7:12: error: template argument 2 is invalid
a.cc: In function 'void dfs(long long int, long long int)':
a.cc:15:42: error: request for member 'size' in 'v[x]', which is of non-class type 'int'
   15 |                 for(long long i=0;i<v[x].size();i++)
      |                                          ^~~~
a.cc:17:25: error: reference to 'data' is ambiguous
   17 |                         data d;
      |                         ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:4:8: note:                 'struct data'
    4 | struct data {
      |        ^~~~
a.cc:18:27: error: request for member 'to' in 'd', which is of non-class type 'long long int [5100]'
   18 |                         d.to=x;
      |                           ^~
a.cc:19:27: error: request for member 'val' in 'd', which is of non-class type 'long long int [5100]'
   19 |                         d.val=v[x][i].val;
      |                           ^~~
a.cc:19:35: error: invalid types 'int[long long int]' for array subscript
   19 |                         d.val=v[x][i].val;
      |                                   ^
a.cc:20:35: error: invalid types 'int[long long int]' for array subscript
   20 |                         if(x==v[x][i].to)
      |                                   ^
a.cc:22:40: error: invalid types 'int[long long int]' for array subscript
   22 |                                 v1[v[x][i].to].push_back(d);
      |                                        ^
a.cc:25:32: error: invalid types 'int[long long int]' for array subscript
   25 |                         v1[v[x][i].to].push_back(d);
      |                                ^
a.cc:26:33: error: invalid types 'int[long long int]' for array subscript
   26 |                         dfs(v[x][i].to,1);
      |                                 ^
a.cc:32:43: error: request for member 'size' in 'v1[x]', which is of non-class type 'int'
   32 |                 for(long long i=0;i<v1[x].size();i++)
      |                                           ^~~~
a.cc:34:25: error: reference to 'data' is ambiguous
   34 |                         data d;
      |                         ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:4:8: note:                 'struct data'
    4 | struct data {
      |        ^~~~
a.cc:35:27: error: request for member 'to' in 'd', which is of non-class type 'long long int [5100]'
   35 |                         d.to=v1[x][i].to;
      |                           ^~
a.cc:35:35: error: invalid types 'int[long long int]' for array subscript
   35 |                         d.to=v1[x][i].to;
      |                                   ^
a.cc:36:27: error: request for member 'val' in 'd', which is of non-class type 'long long int [5100]'
   36 |                         d.val=v1[x][i].val;
      |                           ^~~
a.cc:36:36: error: invalid types 'int[long long int]' for array subscript
   36 |                         d.val=v1[x][i].val;
      |                                    ^
a.cc:37:36: error: invalid types 'int[long long int]' for array subscript
   37 |                         if(x==v1[x][i].to)
      |                                    ^
a.cc:39:40: error: invalid types 'int[long long int]' for array subscript
   39 |                                 v[v1[x][i].to].push_back(d);
      |                                        ^
a.cc:41:43: error: invalid types 'int[long long int]' for array subscript
   41 |                                 b[e]=v1[x][i].to;
      |                                           ^
a.cc:42:43: error: invalid types 'int[long long int]' for array subscript
   42 |                                 h[e]=v1[x][i].val;
      |                                           ^
a.cc:46:32: error: invalid types 'int[long long int]' for array subscript
   46 |                         t[v1[x][i].to]++;
      |                                ^
a.cc:47:30: error: request for member 'push_back' in 'v[x]', which is of non-class type 'int'
   47 |                         v[x].push_back(d);
      |                              ^~~~~~~~~
a.cc:49:35: error: invalid types 'int[long long int]' for array subscript
   49 |                         b[e]=v1[x][i].to;
      |                                   ^
a.cc:50:35: error: invalid types 'int[long long int]' for array subscript
   50 |                         h[e]=v1[x][i].val;
      |                                   ^
a.cc:52:34: error: invalid types 'int[long long int]' for array subscript
   52 |                         dfs(v1[x][i].to,0);
      |                                  ^
At global scope:
cc1plus: error: '::main' must return 'int'
a.cc: In function 'int main()':
a.cc:65:17: error: reference to 'data' is ambiguous
   65 |                 data d;
      |                 ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:4:8: note:                 'struct data'
    4 | struct data {
      |        ^~~~
a.cc:66:19: error: request for member 'to' in 'd', which is of non-class type 'long long int [5100]'
   66 |                 d.to=a[i];
      |                   ^~
a.cc:67:19: error: request for member 'val' in 'd', which is of non-class type 'long long int [5100]'
   67 |                 d.val=h[i];
      |                   ^~~
a.cc:68:25: error: request for member 'push_back' in 'v[b[i]]', which is of non-class type 'int'
   68 |                 v[b[i]].push_back(d);
      |                         ^~~~~~~~~
a.cc:74:22: error: request for member 'clear' in 'v[i]', which is of non-class type 'int'
   74 |                 v[i].clear();
      |                      ^~~~~