Language: C++

#include<bits/stdc++.h>
#define INF 2100000000
#define LL long long int
using namespace std;
LL node[1010],i,j,k,n,m,a[1010],b[1010],c[1010],sco[1010]={INF},size[1010],x,y,
   check[1010]={0},sco2[1010]={INF},start,gorl;
int root(int x){
	if(x!=node[x]){
		node[x]=root(node[x]);
		return node[x];
	}
	else return x;
}
int main(void)
{
	cin>>n>>m;
	for(i=1;i<=m;i++) {
		cin>>a[i]>>b[i]>>c[i];
		if(n==b[i]) gorl=a[i];
		if(n==a[i]) start=b[i];
	}
	for(i=1;i<=n;i++) size[i]=1,node[i]=i;
	for(i=1;i<=m;i++) {
		x=a[i],y=b[i];
		x=root(x);
		y=root(y);
		if(x!=y) {
			if(size[x]>=size[y]) node[y]=x;
			else node[x]=y;
		}
	}	
	x=root(start);
	y=root(gorl);
	if(x==y) cout<<"inf"<<endl;
	else {
		for(i=1;i<=m;i++) {
			if(c[i]>0) {
				c[i]*=-1;
				check[i]=1;
			}
		}
		sco[1]=sco2[1]=0;
		for(i=1;i<=n-1;i++) {
			for(j=1;j<=m;j++) {
				if(sco[a[j]==INF) continue;
				if(sco[b[j]]>sco[a[j]]+c[j]) {
					sco[b[j]]=sco[a[j]]+c[j];
					if(check[j]==1) sco2[b[j]]=sco2[a[j]]+c[j]*-1;
					else sco2[b[j]]=sco[b[j]];
				}
			}
		}
		cout<<sco2[n]<<endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:27: error: reference to 'size' is ambiguous
   22 |         for(i=1;i<=n;i++) size[i]=1,node[i]=i;
      |                           ^~~~
In file included from /usr/include/c++/14/string:53,
                 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/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:5:65: note:                 'long long int size [1010]'
    5 | LL node[1010],i,j,k,n,m,a[1010],b[1010],c[1010],sco[1010]={INF},size[1010],x,y,
      |                                                                 ^~~~
a.cc:28:28: error: reference to 'size' is ambiguous
   28 |                         if(size[x]>=size[y]) node[y]=x;
      |                            ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:5:65: note:                 'long long int size [1010]'
    5 | LL node[1010],i,j,k,n,m,a[1010],b[1010],c[1010],sco[1010]={INF},size[1010],x,y,
      |                                                                 ^~~~
a.cc:28:37: error: reference to 'size' is ambiguous
   28 |                         if(size[x]>=size[y]) node[y]=x;
      |                                     ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:5:65: note:                 'long long int size [1010]'
    5 | LL node[1010],i,j,k,n,m,a[1010],b[1010],c[1010],sco[1010]={INF},size[1010],x,y,
      |                                                                 ^~~~
a.cc:45:49: error: expected ']' before ')' token
   45 |                                 if(sco[a[j]==INF) continue;
      |                                                 ^