标签:png 地址 stream signed 需要 nod http mic The


注意点:
#include<cstdio>
#include<iostream>
#include<queue>
#include<cstring>
#define int long long
using namespace std;
const int MAXN=2e6,MAXM=4e6,INF=2e9,MOD=100003;
struct Edge{
int from,to,w,nxt;
}e[MAXM];
int head[MAXN],edgeCnt=1;
void addEdge(int u,int v,int w){
e[++edgeCnt].from=u;
e[edgeCnt].to=v;
e[edgeCnt].w=w;
e[edgeCnt].nxt=head[u];
head[u]=edgeCnt;
}
struct Node{
int v,dis;
bool operator <(Node another)const{
return dis>another.dis;
}
};
int dis[MAXN],cnt[MAXN];
int s=1;
void dijkstra(){
memset(dis,0x3f,sizeof(dis));
priority_queue<Node> q;
q.push(Node{s,0});
dis[s]=0,cnt[s]=1;
while(!q.empty()){
Node nowNode=q.top();
q.pop();
int nowU=nowNode.v;
for(int i=head[nowU];i;i=e[i].nxt){
int nowV=e[i].to;
if(dis[nowV]>dis[nowU]+e[i].w){
dis[nowV]=dis[nowU]+e[i].w;
cnt[nowV]=cnt[nowU];
q.push(Node{nowV,dis[nowV]});
}else if(dis[nowV]==dis[nowU]+e[i].w){
cnt[nowV]+=cnt[nowU];
cnt[nowV]=cnt[nowV]%MOD;
}
}
}
}
signed main(){
int n,m;
scanf("%lld%lld",&n,&m);
for(int i=1;i<=m;i++){
int x,y;
scanf("%lld%lld",&x,&y);
addEdge(x,y,1);
addEdge(y,x,1);
}
dijkstra();
for(int i=1;i<=n;i++){
cnt[i]=cnt[i]%MOD;
printf("%lld\n",cnt[i]);
}
return 0;
}
标签:png 地址 stream signed 需要 nod http mic The
原文地址:https://www.cnblogs.com/zbsy-wwx/p/11797581.html