Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#define Rep(i,a,b) for(register int i=(a),i##end=(b);i<=i##end;++i)
using namespace std;
template<typename T>inline void read(T &x)
{
	T s=0,f=1;static char c;
	for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())s=s*10+(c^48);
	x=s*f;
}
const int MAXN=2e5+7;
static int in[MAXN],n,m,e,dis[MAXN],head[MAXN];
static struct edge
{
	int v,nxt,w;
}p[MAXN<<1];
inline void add(int u,int v,int w)
{p[++e].v=v;p[e].w=w;p[e].nxt=head[u];head[u]=e;}
inline void End(){printf("No\n");exit(0);}
void dfs(int u)
{
	for(register int v=head[u];v;v=p[v].nxt)
	{
		if(dis[p[v].v]!=dis[0]&&dis[p[v].v]!=dis[u]+p[v].w)End();
		dis[p[v].v]=dis[u]+p[v].w;
		if(!(--in[p[v].v]))dfs(p[v].v);
	}
}
const int inf=INT_MAX/3;
int main()
{
	read(n);read(m);
	static int u,v,w,root=0;
	dis[0]=inf;
	Rep(i,1,m)read(u),read(v),read(w),add(u,v,w),++in[v],dis[u]=dis[v]=inf;
	Rep(i,1,n)if(!in[i]){root=i;break;}
	if(!root)End();
	dis[root]=0;
	dfs(root);
	Rep(i,1,n)if(dis[i]==dis[0])End();
	printf("Yes\n");
	return 0;
}


Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:26:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   26 |         for(register int v=head[u];v;v=p[v].nxt)
      |                          ^
a.cc: At global scope:
a.cc:33:15: error: 'INT_MAX' was not declared in this scope
   33 | const int inf=INT_MAX/3;
      |               ^~~~~~~
a.cc:6:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    5 | #include<cstring>
  +++ |+#include <climits>
    6 | #define Rep(i,a,b) for(register int i=(a),i##end=(b);i<=i##end;++i)
a.cc: In function 'int main()':
a.cc:39:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   39 |         Rep(i,1,m)read(u),read(v),read(w),add(u,v,w),++in[v],dis[u]=dis[v]=inf;
      |             ^
a.cc:6:37: note: in definition of macro 'Rep'
    6 | #define Rep(i,a,b) for(register int i=(a),i##end=(b);i<=i##end;++i)
      |                                     ^
a.cc:39:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   39 |         Rep(i,1,m)read(u),read(v),read(w),add(u,v,w),++in[v],dis[u]=dis[v]=inf;
      |             ^
a.cc:6:43: note: in definition of macro 'Rep'
    6 | #define Rep(i,a,b) for(register int i=(a),i##end=(b);i<=i##end;++i)
      |                                           ^
a.cc:40:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   40 |         Rep(i,1,n)if(!in[i]){root=i;break;}
      |             ^
a.cc:6:37: note: in definition of macro 'Rep'
    6 | #define Rep(i,a,b) for(register int i=(a),i##end=(b);i<=i##end;++i)
      |                                     ^
a.cc:40:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   40 |         Rep(i,1,n)if(!in[i]){root=i;break;}
      |             ^
a.cc:6:43: note: in definition of macro 'Rep'
    6 | #define Rep(i,a,b) for(register int i=(a),i##end=(b);i<=i##end;++i)
      |                                           ^
a.cc:44:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   44 |         Rep(i,1,n)if(dis[i]==dis[0])End();
      |             ^
a.cc:6:37: note: in definition of macro 'Rep'
    6 | #define Rep(i,a,b) for(register int i=(a),i##end=(b);i<=i##end;++i)
      |                                     ^
a.cc:44:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   44 |         Rep(i,1,n)if(dis[i]==dis[0])End();
      |             ^
a.cc:6:43: note: in definition of macro 'Rep'
    6 | #define Rep(i,a,b) for(register int i=(a),i##end=(b);i<=i##end;++i)
      |                                           ^