Language: C++

#include<cstdio>
#include<cstring>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
const int MAXN=10005,MAXE=10005;

int n,m;

struct Edge
{
	int x,v1,v2;
	Edge *next;
	Edge():next(NULL){}
	Edge(int a,int b,int c):x(a),v1(b),v2(c),next(NULL){}
}edge[MAXE*2],*ecnt=edge,*adj[MAXN];

void AddEdge(int u,int v,int a,int b)
{
	*ecnt=Edge(v,a,b);
	ecnt->next=adj[u];
	adj[u]=ecnt++;
}

typedef pair<int,int> Po;
priority_queue<Po,vector<Po>,greater<Po> > Q;
long long dis1[MAXN],dis2[MAXN];

void Dijkstra1(int S)
{
	memset(dis1,0x3F,sizeof dis1);
	dis1[S]=0;
	Q.push(make_pair(0,S));
	while(!Q.empty())
	{
		Po t=Q.top();Q.pop();
		if(dis1[t.second]<t.first)
			continue;
		for(Edge *p=adj[t.second];p;p=p->next)
			if(dis1[p->x]>dis1[t.second]+p->v1)
			{
				dis1[p->x]=dis1[t.second]+p->v1;
				Q.push(make_pair(dis1[p->x],p->x));
			}
	}
}
void Dijkstra2(int S)
{
	memset(dis2,0x3F,sizeof dis2);
	dis2[S]=0;
	Q.push(make_pair(0,S));
	while(!Q.empty())
	{
		Po t=Q.top();Q.pop();
		if(dis2[t.second]<t.first)
			continue;
		for(Edge *p=adj[t.second];p;p=p->next)
			if(dis2[p->x]>dis2[t.second]+p->v2)
			{
				dis2[p->x]=dis2[t.second]+p->v2;
				Q.push(make_pair(dis2[p->x],p->x));
			}
	}
}

pair<long long,int> ans[MAXN];

int main()
{
	int S,T;
	scanf("%d%d%d%d",&n,&m,&S,&T);
	for(int q=1,u,v,a,b;q<=m;q++)
	{
		scanf("%d%d%d%d",&u,&v,&a,&b);
		AddEdge(u,v,a,b);
		AddEdge(v,u,a,b);
	}
	
	Dijkstra1(S);
	Dijkstra2(T);
	
	for(int i=1;i<=n;i++)
		ans[i]=make_pair(dis1[i]+dis2[i],i);
	sort(ans+1,ans+n+1);
	int k=1;
	
	for(int i=0;i<n;i++)
	{
		while(ans[k].second<=i)
			k++;
		printf("%lld\n",1000000000000000LL-ans[k].first);
	}
	
	return 0;
}
#include<cstdio>
#include<cstring>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
const int MAXN=10005,MAXE=10005;

int n,m;

struct Edge
{
	int x,v1,v2;
	Edge *next;
	Edge():next(NULL){}
	Edge(int a,int b,int c):x(a),v1(b),v2(c),next(NULL){}
}edge[MAXE*2],*ecnt=edge,*adj[MAXN];

void AddEdge(int u,int v,int a,int b)
{
	*ecnt=Edge(v,a,b);
	ecnt->next=adj[u];
	adj[u]=ecnt++;
}

typedef pair<int,int> Po;
priority_queue<Po,vector<Po>,greater<Po> > Q;
long long dis1[MAXN],dis2[MAXN];

void Dijkstra1(int S)
{
	memset(dis1,0x3F,sizeof dis1);
	dis1[S]=0;
	Q.push(make_pair(0,S));
	while(!Q.empty())
	{
		Po t=Q.top();Q.pop();
		if(dis1[t.second]<t.first)
			continue;
		for(Edge *p=adj[t.second];p;p=p->next)
			if(dis1[p->x]>dis1[t.second]+p->v1)
			{
				dis1[p->x]=dis1[t.second]+p->v1;
				Q.push(make_pair(dis1[p->x],p->x));
			}
	}
}
void Dijkstra2(int S)
{
	memset(dis2,0x3F,sizeof dis2);
	dis2[S]=0;
	Q.push(make_pair(0,S));
	while(!Q.empty())
	{
		Po t=Q.top();Q.pop();
		if(dis2[t.second]<t.first)
			continue;
		for(Edge *p=adj[t.second];p;p=p->next)
			if(dis2[p->x]>dis2[t.second]+p->v2)
			{
				dis2[p->x]=dis2[t.second]+p->v2;
				Q.push(make_pair(dis2[p->x],p->x));
			}
	}
}

pair<long long,int> ans[MAXN];

int main()
{
	int S,T;
	scanf("%d%d%d%d",&n,&m,&S,&T);
	for(int q=1,u,v,a,b;q<=m;q++)
	{
		scanf("%d%d%d%d",&u,&v,&a,&b);
		AddEdge(u,v,a,b);
		AddEdge(v,u,a,b);
	}
	
	Dijkstra1(S);
	Dijkstra2(T);
	
	for(int i=1;i<=n;i++)
		ans[i]=make_pair(dis1[i]+dis2[i],i);
	sort(ans+1,ans+n+1);
	int k=1;
	
	for(int i=0;i<n;i++)
	{
		while(ans[k].second<=i)
			k++;
		printf("%lld\n",1000000000000000LL-ans[k].first);
	}
	
	return 0;
}


Compiler output:
a.cc:103:11: error: redefinition of 'const int MAXN'
  103 | const int MAXN=10005,MAXE=10005;
      |           ^~~~
a.cc:7:11: note: 'const int MAXN' previously defined here
    7 | const int MAXN=10005,MAXE=10005;
      |           ^~~~
a.cc:103:22: error: redefinition of 'const int MAXE'
  103 | const int MAXN=10005,MAXE=10005;
      |                      ^~~~
a.cc:7:22: note: 'const int MAXE' previously defined here
    7 | const int MAXN=10005,MAXE=10005;
      |                      ^~~~
a.cc:105:5: error: redefinition of 'int n'
  105 | int n,m;
      |     ^
a.cc:9:5: note: 'int n' previously declared here
    9 | int n,m;
      |     ^
a.cc:105:7: error: redefinition of 'int m'
  105 | int n,m;
      |       ^
a.cc:9:7: note: 'int m' previously declared here
    9 | int n,m;
      |       ^
a.cc:107:8: error: redefinition of 'struct Edge'
  107 | struct Edge
      |        ^~~~
a.cc:11:8: note: previous definition of 'struct Edge'
   11 | struct Edge
      |        ^~~~
a.cc:113:2: error: conflicting declaration 'int edge [20010]'
  113 | }edge[MAXE*2],*ecnt=edge,*adj[MAXN];
      |  ^~~~
a.cc:17:2: note: previous declaration as 'Edge edge [20010]'
   17 | }edge[MAXE*2],*ecnt=edge,*adj[MAXN];
      |  ^~~~
a.cc:113:16: error: conflicting declaration 'int* ecnt'
  113 | }edge[MAXE*2],*ecnt=edge,*adj[MAXN];
      |                ^~~~
a.cc:17:16: note: previous declaration as 'Edge* ecnt'
   17 | }edge[MAXE*2],*ecnt=edge,*adj[MAXN];
      |                ^~~~
a.cc:113:27: error: conflicting declaration 'int* adj [10005]'
  113 | }edge[MAXE*2],*ecnt=edge,*adj[MAXN];
      |                           ^~~
a.cc:17:27: note: previous declaration as 'Edge* adj [10005]'
   17 | }edge[MAXE*2],*ecnt=edge,*adj[MAXN];
      |                           ^~~
a.cc:115:6: error: redefinition of 'void AddEdge(int, int, int, int)'
  115 | void AddEdge(int u,int v,int a,int b)
      |      ^~~~~~~
a.cc:19:6: note: 'void AddEdge(int, int, int, int)' previously defined here
   19 | void AddEdge(int u,int v,int a,int b)
      |      ^~~~~~~
a.cc:123:44: error: redefinition of 'std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, std::greater<std::pair<int, int> > > Q'
  123 | priority_queue<Po,vector<Po>,greater<Po> > Q;
      |                                            ^
a.cc:27:44: note: 'std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, std::greater<std::pair<int, int> > > Q' previously declared here
   27 | priority_queue<Po,vector<Po>,greater<Po> > Q;
      |                                            ^
a.cc:124:11: error: redefinition of 'long long int dis1 [10005]'
  124 | long long dis1[MAXN],dis2[MAXN];
      |           ^~~~
a.cc:28:11: note: 'long long int dis1 [10005]' previously declared here
   28 | long long dis1[MAXN],dis2[MAXN];
      |           ^~~~
a.cc:124:22: error: redefinition of 'long long int dis2 [10005]'
  124 | long long dis1[MAXN],dis2[MAXN];
      |                      ^~~~
a.cc:28:22: note: 'long long int dis2 [10005]' previously declared here
   28 | long long dis1[MAXN],dis2[MAXN];
      |                      ^~~~
a.cc:126:6: error: redefinition of 'void Dijkstra1(int)'
  126 | void Dijkstra1(int S)
      |      ^~~~~~~~~
a.cc:30:6: note: 'void Dijkstra1(int)' previously defined here
   30 | void Dijkstra1(int S)
      |      ^~~~~~~~~
a.cc:144:6: error: redefinition of 'void Dijkstra2(int)'
  144 | void Dijkstra2(int S)
      |      ^~~~~~~~~
a.cc:48:6: note: 'void Dijkstra2(int)' previously defined here
   48 | void Dijkstra2(int S)
      |      ^~~~~~~~~
a.cc:163:21: error: redefinition of 'std::pair<long long int, int> ans [10005]'
  163 | pair<long long,int> ans[MAXN];
      |                     ^~~
a.cc:67:21: note: 'std::pair<long long int, int> ans [10005]' previously defined here
   67 | pair<long long,int> ans[MAXN];
      |                     ^~~
a.cc:165:5: error: redefinition of 'int main()'
  165 | int main()
      |     ^~~~
a.cc:69:5: note: 'int main()' previously defined here
   69 | int main()
      |     ^~~~