[模板]SPFA
1 pt.push(pn);dt[0][1]=0; 2 while(!pt.empty()){ 3 p pj;pj=pt.top();pt.pop();ved[pj.ds][pj.np]=0; 4 for(ll i=fir[pj.np];i;i=ls[i].l){ 5 if(search(pj.np,ls[i].e)+dt[pj.ds][pj.np]<dt[pj.ds][ls[i].e]){ 6 dt[pj.ds][ls[i].e]=search(pj.np,ls[i].e)+dt[pj.ds][pj.np]; 7 if(ved[pj.ds][ls[i].e]==0){ 8 pn.ds=pj.ds; 9 pn.nd=dt[pj.ds][ls[i].e]; 10 pn.np=ls[i].e; 11 pt.push(pn); 12 } 13 ved[pj.ds][i]=1; 14 } 15 } 16 }
$Fate \ is \ Fake$