Submission #3750

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
37502013-08-31 08:06:00qja0950Following Flow (kriii1_F)C++98
0 / 1
0 ms1108 KiB
#include <stdio.h>
int n, m;
int line[31][31][2];
int x, y, z, cnt, now, how;
double plus[51][31], ans=0;
int times;
int main() {
scanf("%d %d", &n, &m);
int i, j;
for(i=1; i<=m; i++) {
scanf("%d %d %d", &x, &y, &z);
line[x][0][0]++;
line[x][line[x][0][0]][0]=y;
line[x][line[x][0][0]][1]=z;
}
plus[0][0]=1;
while(times<=1000) {
for(i=0; i<n; i++) {
how=line[i][0][0];
if(how==0 || plus[times%51][i]==0) continue;
for(j=1; j<=how; j++) {
plus[(times+line[i][j][1])%51][line[i][j][0]]+=(1./how)*plus[times%51][i];
}
plus[times%51][i]=0;
}
if(plus[times%51][n]!=0) {
ans+=(plus[times%51][n]*times);
plus[times%51][n]=0;
}
times++;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...