HDU-4318-Power transmission

这个题就是Spfa了,没什么说的了

代码:

#include
#include
#include
#include
using namespace std;
const int inf=1<<29;
const int maxn=5e4+1000;
const int maxm=maxn*51;
int n,e,head[maxn],pnt[maxm],nxt[maxm];
double cost[maxm],dist[maxn];
bool vis[maxn];
queue q;
void AddEdge(int u,int v,double c)
{
    pnt[e]=v;nxt[e]=head[u];cost[e]=c;head[u]=e++;
}
double Spfa(int st,int des)
{
    memset(dist,0,sizeof(dist));
    dist[st]=1;
    q.push(st);
    while(!q.empty())
    {
        int u=q.front();
        vis[u]=0;
        q.pop();
        for(int i=head[u];i!=-1;i=nxt[i])
            if(dist[pnt[i]]


你可能感兴趣的:(ACM,HDU)