Submission #3515

#TimeUsernameProblemLanguageResultExecution timeMemory
3515pichuliaFollowing Flow (kriii1_F)C++98
0 / 1
0 ms1304 KiB
#include<stdio.h> #include<time.h> int n,m; int a[35][35][3]; int an[35]; double d[3][35][250]; double la; long start; long end; 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; } start = clock(); d[0][0][0]=1; int i1,i2; double op; for(i=0;i<=25000000;++i){ i2=0; i1=i%200; if(i1>=100) i2=1,i1-=100; if(i1==0){ for(j=0;j<=n;j++) for(k=0;k<=200;++k) d[(i2+1)%2][j][k]=0; } for(j=0;j<n;++j){ if(an[j]!=0){ op=d[i2][j][i1]/(double)an[j]; for(k=an[j];k>=1;--k){ if(i1+a[j][k][1]>=100) d[(i2+1)%2][a[j][k][0]][i1+a[j][k][1]-100]+=op; else d[i2][a[j][k][0]][i1+a[j][k][1]]+=op; } } } la+=d[i2][n][i1]*i; end = clock(); if(end-start>390) break; } printf("%lf",la); }
#Verdict Execution timeMemoryGrader output
Fetching results...