#include #include #include #define N 10005 using namespace std; int n,m,num,adj[N],q[N]; bool f[N]; double low[N],p[N],w[N]; struct edge { int v,pre; double w; edge(){} edge(int vv,double ww,int p){v=vv;w=ww;pre=p;} }e[N*5]; void insert(int u,int v,double w) { e[num]=edge(v,w,adj[u]); adj[u]=num++; } void spfa(int x) { int i,v,head=0,tail=0; memset(f,0,sizeof(f)); memset(low,-0x3f,sizeof(low)); low[x]=0; q[++tail]=x; while(head!=tail) { x=q[head=(head+1)%N]; f[x]=0; for(i=adj[x];~i;i=e[i].pre) if(low[v=e[i].v]