Language: C++

#include<bits/stdc++.h>
using namespace std;
long long d[100005];
int n,m;
bool vis[100005],used[100005];
vector<int>v;
vector<int>e;

void read(int& x)
{
    char c=getchar();
    x=0;
    while(c<'0'||c>'9')c=getchar();
    while(c>='0'&&c<='9')
    {
        x=x*10+c-'0';
        c=getchar();
    }
}

bool dfs(int fa)
{
    vis[fa]=1;
    used[fa]=1;
    for(int i=0;i<v[fa].size();i++)
    {
        int y=v[fa][i];
        int z=e[fa][i];
        if(d[y]>d[fa]+z)//如果可以更新
        {
            if(vis[y])return 1;//如果新点已经被访问，返回1
            d[y]=d[fa]+z;//更新点权
            if(dfs(y))return 1;//如果在继续下一层dfs时返回了0,这一层也返回0
        }
    }
    vis[fa]=0;撤除vis标记
    return 0;
}
int main()
{
    read(n);
    read(m);
    for(int i=1;i<=n;i++)
    {
        d[i]=200000000000ll;
    }
    for(int i=1;i<=m;i++)
    {
        int x,y,z;
        read(x);
        read(y);
        read(z);
        v[x].push_back(y);
        e[x].push_back(z);
        v[y].push_back(x);
        e[y].push_back(-z);
    }
    bool ok=0;
    for(int i=1;i<=n;i++)
    {
        if(!used[i])//没走过就走
        {
            d[i]=0;
            if(dfs(i))
            {
                ok=1;
            }
        }
    }
    if(ok)printf("No\n");
    else printf("Yes\n");
    return 0;
}

Compiler output:
a.cc: In function 'bool dfs(int)':
a.cc:25:25: error: request for member 'size' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)fa))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   25 |     for(int i=0;i<v[fa].size();i++)
      |                         ^~~~
a.cc:27:20: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   27 |         int y=v[fa][i];
      |                    ^
a.cc:28:20: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   28 |         int z=e[fa][i];
      |                    ^
a.cc:36:15: error: '\U000064a4\U00009664vis\U00006807\U00008bb0' was not declared in this scope
   36 |     vis[fa]=0;撤除vis标记
      |               ^~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:53:14: error: request for member 'push_back' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)x))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   53 |         v[x].push_back(y);
      |              ^~~~~~~~~
a.cc:54:14: error: request for member 'push_back' in 'e.std::vector<int>::operator[](((std::vector<int>::size_type)x))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   54 |         e[x].push_back(z);
      |              ^~~~~~~~~
a.cc:55:14: error: request for member 'push_back' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)y))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   55 |         v[y].push_back(x);
      |              ^~~~~~~~~
a.cc:56:14: error: request for member 'push_back' in 'e.std::vector<int>::operator[](((std::vector<int>::size_type)y))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   56 |         e[y].push_back(-z);
      |              ^~~~~~~~~
a.cc: In function 'bool dfs(int)':
a.cc:36:12: warning: control reaches end of non-void function [-Wreturn-type]
   36 |     vis[fa]=0;撤除vis标记
      |     ~~~~~~~^~