Language: C++

#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define RG register int
#define rep(i,a,b)	for(RG i=a;i<=b;++i)
#define per(i,a,b)	for(RG i=a;i>=b;--i)
#define ll long long
#define inf (1<<29)
#define maxn 10005
#define maxm 20005
#define add(x,y,z,w) e[++cnt]=(E){y,head[x],z,w},head[x]=cnt
using namespace std;
int n,m,cnt,ans;
int head[maxn],dis[maxn],cost[maxn],vis[maxn;
struct E{
	int v,next,val,co;
}e[maxm<<1];
inline int read()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}

void spfa()
{
	queue<int> que;que.push(1);
	cost[1]=dis[1]=0;
	RG u,v;
	while(!que.empty())
	{
		u=que.front(),que.pop(),vis[u]=0;
		for(RG i=head[u];i;i=e[i].next)
		{
			v=e[i].v;
			if((dis[v]>dis[u]+e[i].val)||(dis[v]==dis[u]+e[i].val && cost[v]>e[i].co))
			{
				dis[v]=dis[u]+e[i].val,cost[v]=e[i].co;
				if(!vis[v])	vis[v]=1,que.push(v);
			}
		}
	}
}

int main()
{
	while(1)
	{
		n=read(),m=read();
		if(!n)	return 0;
		memset(cost,63,sizeof(cost));
		memset(head,0,sizeof(head));
		memset(dis,63,sizeof(dis));
		memset(vis,0,sizeof(vis));
		cnt=ans=0;
		for(RG i=1,a,b,c,d;i<=m;i++)
		{
			a=read(),b=read(),c=read(),d=read();
			add(a,b,c,d),add(b,a,c,d);
		}
		spfa();
		rep(i,2,n) ans+=cost[i];
		printf("%d\n",ans);
	}

	return 0;
}


Compiler output:
a.cc:20:45: error: expected ']' before ';' token
   20 | int head[maxn],dis[maxn],cost[maxn],vis[maxn;
      |                                             ^
a.cc: In function 'void spfa()':
a.cc:36:12: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   36 |         RG u,v;
      |            ^
a.cc:36:14: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   36 |         RG u,v;
      |              ^
a.cc:39:41: error: 'vis' was not declared in this scope; did you mean 'dis'?
   39 |                 u=que.front(),que.pop(),vis[u]=0;
      |                                         ^~~
      |                                         dis
a.cc:40:24: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   40 |                 for(RG i=head[u];i;i=e[i].next)
      |                        ^
a.cc: In function 'int main()':
a.cc:61:24: error: 'vis' was not declared in this scope; did you mean 'dis'?
   61 |                 memset(vis,0,sizeof(vis));
      |                        ^~~
      |                        dis
a.cc:63:24: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   63 |                 for(RG i=1,a,b,c,d;i<=m;i++)
      |                        ^
a.cc:63:28: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   63 |                 for(RG i=1,a,b,c,d;i<=m;i++)
      |                            ^
a.cc:63:30: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   63 |                 for(RG i=1,a,b,c,d;i<=m;i++)
      |                              ^
a.cc:63:32: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   63 |                 for(RG i=1,a,b,c,d;i<=m;i++)
      |                                ^
a.cc:63:34: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   63 |                 for(RG i=1,a,b,c,d;i<=m;i++)
      |                                  ^
a.cc:69:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   69 |                 rep(i,2,n) ans+=cost[i];
      |                     ^
a.cc:11:32: note: in definition of macro 'rep'
   11 | #define rep(i,a,b)      for(RG i=a;i<=b;++i)
      |                                ^