直接爆0了
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;
int n,m;
struct node{
int to,next,value;
}edgn[10005],edgnl[10005];
int tot,totl,headl[10005],head[10005];
bool be[10005],bel[10005];
int dist[10005],distl[10005];
void add(int x,int y,int z){
tot++;
edgn[tot].to=y;
edgn[tot].value=z;
edgn[tot].next=head[x];
head[x]=tot;
}
void addl(int x,int y,int v){
totl++;
edgnl[totl].to=y;
edgnl[totl].value=v;
edgnl[totl].next=headl[x];
headl[x]=totl;
}
void dj(){
memset(dist,0x3f,sizeof(dist));
priority_queue<PII,vector<PII>,greater<PII> > heap;
dist[1]=0;
heap.push({1,0});
while(!heap.empty()){
PII w=heap.top();
heap.pop();
int ver=w.first,num=w.second;
if(be[ver]) continue;
be[ver]=1;
for(int i=head[ver];i!=0;i=edgn[i].next){
int x=edgn[i].to;
if(dist[x]>dist[ver]+edgn[i].value){
dist[x]=dist[ver]+edgn[i].value;
heap.push({x,dist[x]});
}
}
}
}
void djl(){
memset(distl,0x3f,sizeof(distl));
priority_queue<PII,vector<PII>,greater<PII> > heapl;
distl[1]=0;
heapl.push({1,0});
while(!heapl.empty()){
PII wl=heapl.top();
heapl.pop();
int verl=wl.first,numl=wl.second;
if(bel[verl]) continue;
bel[verl]=1;
for(int i=headl[verl];i!=0;i=edgnl[i].next){
int xl=edgnl[i].to;
if(distl[xl]>distl[verl]+edgnl[i].value){
distl[xl]=distl[verl]+edgnl[i].value;
heapl.push({xl,distl[xl]});
}
}
}
}
int main(){
cin>>n>>m;
while(m--){
int a,b,c;
cin>>a>>b>>c;
add(a,b,c);
addl(b,a,c);
}
dj();
djl();
long long ans=0;
for(int i=1;i<=n;i++){
ans+=dist[i]+distl[i];
}
cout<<ans;
return 0;
}