Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
求助!!一直WA~#include<stdio.h> #define eps 1e-8 //The structure of edges. struct edge { int head,tail; double r,c; }edge[220]; bool Bellmenford(int numOfNode,int numOfEdge,double v,int s) { double capital[numOfNode+10]; //The array to represent the nodes. int i,j; bool change=true; capital[s]=v; while(capital[s]+eps <= v) { change=false; for(j=0;j<numOfEdge;j++) { if( (capital[edge[j].tail]+eps)<(capital[edge[j].head]-edge[j].c)*edge[j].r) { capital[edge[j].tail]=( capital[edge[j].head]-edge[j].c )*edge[j].r; change=true; } } if(change==false) { if(capital[s]+eps >v) return true; else return false; } } return true; } int main() { int n,m,s; double v; scanf("%d%d%d%lf",&n,&m,&s,&v); int i; for(i=0;i<m;i++) { scanf("%d%d%lf%lf%lf%lf",&edge[2*i].head,&edge[2*i].tail,&edge[2*i].r,&edge[2*i].c,&edge[2*i+1].r,&edge[2*i+1].c); edge[2*i+1].head=edge[2*i].tail; edge[2*i+1].tail=edge[2*i].head; } if(Bellmenford(n,2*m,v,s)) printf("YES\n"); else printf("NO\n"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator