Submission #3665

# Submission time Handle Problem Language Result Execution time Memory
3665 2013-08-31T07:27:29 Z cki86201 Following Flow (kriii1_F) C++
0 / 1
96 ms 1100 KB
#include<stdio.h>
#include<vector>
#include<time.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<5000){
		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("%.9llf",ans);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1100 KB Output is correct
2 Correct 4 ms 1100 KB Output is correct
3 Correct 56 ms 1100 KB Output is correct
4 Correct 80 ms 1100 KB Output is correct
5 Correct 68 ms 1100 KB Output is correct
6 Correct 56 ms 1100 KB Output is correct
7 Correct 88 ms 1100 KB Output is correct
8 Correct 96 ms 1100 KB Output is correct
9 Incorrect 0 ms 1100 KB Output isn't correct
10 Halted 0 ms 0 KB -