Submission #3111

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
31112013-08-25 09:38:42aintaFollowing Flow (kriii1_F)C++98
1 / 1
0 ms1108 KiB
#include<stdio.h>
int n,m,deg[31],Ed[1001][3];
double w[31][31],C[31],t,t2;
int main()
{
int i,a,b,j,k;
scanf("%d%d",&n,&m);
for(i=0;i<m;i++){
scanf("%d%d%d",&Ed[i][0],&Ed[i][1],&Ed[i][2]);
deg[Ed[i][0]]++;
}
for(i=0;i<m;i++){
a=Ed[i][0],b=Ed[i][1];
if(b!=n)w[a][b]+=1.0/deg[a];
C[a]+=1.0*Ed[i][2]/deg[a];
}
for(i=n-1;i>0;i--){
t=1.0/(1.0-w[i][i]);
w[i][i]=0;
for(j=i-1;j>=0;j--){
t2=t*w[j][i];
w[j][i]=0;
for(k=i-1;k>=0;k--){
w[j][k]+=w[i][k]*t2;
}
C[j]+=C[i]*t2;
}
}
printf("%.10lf\n",1.0/(1.0-w[0][0])*C[0]);
return 0;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...