Submission #3461

#TimeUsernameProblemLanguageResultExecution timeMemory
3461pichuliaFollowing Flow (kriii1_F)C++98
0 / 1
0 ms8192 KiB
#include<stdio.h> int n,m; int a[35][35][3]; int an[35]; double d[35][500105]; double la; int main(){ int i,j,k,in1,in2,in3; scanf("%d %d",&n,&m); for(i=1;i<=m;i++){ scanf("%d %d %d",&in1,&in2,&in3); a[in1][++an[in1]][0]=in2; a[in1][an[in1]][1]=in3; } d[0][0]=1; double op; for(i=0;i<=250000;++i){ for(j=0;j<n;++j){ if(an[j]!=0){ op=d[j][i]/(double)an[j]; for(k=an[j];k>=1;--k) d[a[j][k][0]][i+a[j][k][1]]+=op; } } la+=d[n][i]*i; } printf("%lf",la); }
#Verdict Execution timeMemoryGrader output
Fetching results...