Language: C++

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
const int N=2000005;
const long long mod=1e9+7;
const long long inf=1e17;
struct edge {
  int to,nxt,val;
}e[N<<2];
int cnt=0,head[N],n,m,tot[N<<1],tot1[N<<1],s,t,in[N];
long long dis[N<<1],dis1[N<<1],mindis,ans=0;
queue<int> q,qtop;
vector<int> v[N];
bool vis[N];
void addedge(int x,int y,int v) {
  ++cnt;
  e[cnt].to=y;e[cnt].nxt=head[x];e[cnt].val=v;head[x]=cnt;
}
void spfa(int x,long long *dis) {
  memset(vis,0,sizeof(vis));
  for (int i=0;i<=n+1;++i) dis[i]=inf;
  dis[x]=0;
  while(!q.empty()) q.pop();
  q.push(x);vis[x]=1;
  while(!q.empty()) {
    int u=q.front();
    q.pop();
    vis[u]=0;
    for (int i=head[u];~i;i=e[i].nxt) {
      int v=e[i].to;
      if((dis[u]+1ll*e[i].val)<dis[v]) {
        dis[v]=dis[u]+e[i].val;
        if(!vis[v]) {
          q.push(v);
          vis[v]=1;
        }
      }
    }
  }
  return ;
}
void top(int x,long long *dis,int *tot) {
  for (int i=1;i<=n;++i) {
    v[i].clear();
    for (int j=head[i];~j;j=e[j].nxt) {
      int v1=e[j].to;
      if((dis[i]+e[j].val)==dis[v1]) {
        v[i].push_back(v1);
        ++in[v1];
      }
    }
  }
  while(!qtop.empty()) qtop.pop();
  tot[x]=1;qtop.push(x);
  while(!qtop.empty()) {
    int u=qtop.front();
    qtop.pop();
    for (int i=0;i<v[u].size();++i) {
      int x=v[u][i];
      in[x]--;
      if(in[x]==0) {
        qtop.push(x);
      }
      tot[x]=1ll*(tot[x]+tot[u])%mod;
    }
  }
}
int main() {
  memset(head,-1,sizeof(head));
  scanf("%d%d",&n,&m);
  scanf("%d%d",&s,&t);
  for (int i=1;i<=m;++i) {
    int x,y,v;
    scanf("%d%d%d",&x,&y,&v);
    addedge(x,y,v);
    addedge(y,x,v);
  }
  spfa(s,dis);
  top(s,dis,tot);
  spfa(t,dis1);
  top(t,dis1,tot1);
  mindis=dis[t];
  ans=1ll*tot[t]*(1ll*tot[t])%mod;
  for (int i=1;i<=n;++i) {
    if((dis[i]==dis1[i]) && (dis[i]*2ll==dis[t])) {
      ans=(ans-1ll*tot[i]*tot[i]%mod*tot1[i]*tot1[i]%mod+mod*2ll)%mod;
    }
  }
  for (int x=1;x<=n;++x) {
    for (int j=head[x];~j;j=e[j].nxt) {
      int v1=e[j].to;
      if(((dis[x]+dis1[v1]+e[j].val)==dis[t]) && (dis[x]*2<dis[t]) && (dis1[v1]*2<dis[t])) {        ans=(ans-1ll*tot[x]*tot[x]%mod*tot1[v]*tot1[v]%mod+mod*2ll)%mod;
      }
    }
  }
  printf("%lld\n",(ans+mod)%mod);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:96:136: error: invalid types 'int [4000010][std::vector<int> [2000005]]' for array subscript
   96 |       if(((dis[x]+dis1[v1]+e[j].val)==dis[t]) && (dis[x]*2<dis[t]) && (dis1[v1]*2<dis[t])) {        ans=(ans-1ll*tot[x]*tot[x]%mod*tot1[v]*tot1[v]%mod+mod*2ll)%mod;
      |                                                                                                                                        ^
a.cc:96:144: error: invalid types 'int [4000010][std::vector<int> [2000005]]' for array subscript
   96 |       if(((dis[x]+dis1[v1]+e[j].val)==dis[t]) && (dis[x]*2<dis[t]) && (dis1[v1]*2<dis[t])) {        ans=(ans-1ll*tot[x]*tot[x]%mod*tot1[v]*tot1[v]%mod+mod*2ll)%mod;
      |                                                                                                                                                ^