Language: C++

#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
#define N 100010
vector<int> p[N];
vector<int> q[N];
int vis[N],s[N];
int Spfa(int x)
{
    int i,j,k,t,mx,mi;
    queue<int> Q;
    vis[x]=1;
    s[x]=0;
    Q.push(x);
    mx=0;
    mi=0;
    while(!Q.empty())
    {
        t=Q.front();
        Q.pop();
        k=p[t].size();
        for(i=0;i<k;i++)
        {
            j=p[t][i];
            if(vis[j]==0)
            {
                s[j]=s[t]+q[t][i];
                mx=max(mx,s[j]);
                mi=min(mi,s[j]);
                if(mx-mi>1000000000)
                    return 0;
                vis[j]=1;
                Q.push(j);
            }
            else
            if(vis[j]==1&&(s[j]!=s[t]+q[t][i]))
                    return 0;
        }
    }
    return 1;
}
int main()
{
    int n,m,x,y,z,i,j,k,flag=1;
    scanf("%d%d",&n,&m);
    for(i=1;i<=m;i++)
    {
        scanf("%d%d%d",&x,&y,&z);
        p[x].push_back(y);
        p[y].push_back(x);
        q[x].push_back(z);
        q[y].push_back(-z);
    }
    for(i=1;i<=n;i++)
    if(vis[i]==0)
    {
        j=Spfa(i);
        if(j==0)
        {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
#define N 100010
vector<int> p[N];
vector<int> q[N];
int vis[N],s[N];
int Spfa(int x)
{
    int i,j,k,t,mx,mi;
    queue<int> Q;
    vis[x]=1;
    s[x]=0;
    Q.push(x);
    mx=0;
    mi=0;
    while(!Q.empty())
    {
        t=Q.front();
        Q.pop();
        k=p[t].size();
        for(i=0;i<k;i++)
        {
            j=p[t][i];
            if(vis[j]==0)
            {
                s[j]=s[t]+q[t][i];
                mx=max(mx,s[j]);
                mi=min(mi,s[j]);
                if(mx-mi>1000000000)
                    return 0;
                vis[j]=1;
                Q.push(j);
            }
            else
            if(vis[j]==1&&(s[j]!=s[t]+q[t][i]))
                    return 0;
        }
    }
    return 1;
}
int main()
{
    int n,m,x,y,z,i,j,k,flag=1;
    scanf("%d%d",&n,&m);
    for(i=1;i<=m;i++)
    {
        scanf("%d%d%d",&x,&y,&z);
        p[x].push_back(y);
        p[y].push_back(x);
        q[x].push_back(z);
        q[y].push_back(-z);
    }
    for(i=1;i<=n;i++)
    if(vis[i]==0)
    {
        j=Spfa(i);
        if(j==0)
        {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


Compiler output:
a.cc:77:13: error: redefinition of 'std::vector<int> p [100010]'
   77 | vector<int> p[N];
      |             ^
a.cc:8:13: note: 'std::vector<int> p [100010]' previously declared here
    8 | vector<int> p[N];
      |             ^
a.cc:78:13: error: redefinition of 'std::vector<int> q [100010]'
   78 | vector<int> q[N];
      |             ^
a.cc:9:13: note: 'std::vector<int> q [100010]' previously declared here
    9 | vector<int> q[N];
      |             ^
a.cc:79:5: error: redefinition of 'int vis [100010]'
   79 | int vis[N],s[N];
      |     ^~~
a.cc:10:5: note: 'int vis [100010]' previously declared here
   10 | int vis[N],s[N];
      |     ^~~
a.cc:79:12: error: redefinition of 'int s [100010]'
   79 | int vis[N],s[N];
      |            ^
a.cc:10:12: note: 'int s [100010]' previously declared here
   10 | int vis[N],s[N];
      |            ^
a.cc:80:5: error: redefinition of 'int Spfa(int)'
   80 | int Spfa(int x)
      |     ^~~~
a.cc:11:5: note: 'int Spfa(int)' previously defined here
   11 | int Spfa(int x)
      |     ^~~~
a.cc:114:5: error: redefinition of 'int main()'
  114 | int main()
      |     ^~~~
a.cc:45:5: note: 'int main()' previously defined here
   45 | int main()
      |     ^~~~