Submission #3953

#TimeUsernameProblemLanguageResultExecution timeMemory
3953cki86201Following Flow (kriii1_F)C++98
0 / 1
0 ms1100 KiB
#include<stdio.h> struct edge{ int st,en,len; }; edge data[1005]; long double t[2][35],p[2][35]; long double cnt[35]; int n,m; int main() { long double ans=0; int s=0, e=1, ct=0; scanf("%d%d",&n,&m); for(int i=0;i<m;i++){ scanf("%d%d%d",&data[i].st,&data[i].en,&data[i].len); cnt[data[i].st]++; } p[s][0]=1; while(++ct<10000){ for(int i=0;i<=n;i++)p[e][i]=t[e][i]=0; for(int i=0;i<m;i++){ p[e][data[i].en]+=p[s][data[i].st]/cnt[data[i].st]; t[e][data[i].en]+=(t[s][data[i].st]+data[i].len*p[s][data[i].st])/cnt[data[i].st]; } ans+=t[e][n]; s=!s; e=!e; } printf("%.9lf",ans); } /* #include<stdlib.h> int main() { freopen("input.txt","w",stdout); for(int i=0;i<1000;i++){ printf("%d %d 50\n",rand()%30,rand()%30); } }*/
#Verdict Execution timeMemoryGrader output
Fetching results...