Submission #3968

# Submission time Handle Problem Language Result Execution time Memory
3968 2013-08-31T09:47:12 Z pichulia Following Flow (kriii1_F) C++
0 / 1
296 ms 1508 KB
#include<stdio.h>

int n,m;
int a[35][1005][3];
int an[1005];
int an2[1005];


double d1[3][35];
double d2[3][35];
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);
		if(in1!=n){
			a[in2][++an[in2]][0]=in1;
			a[in2][an[in2]][1]=in3;
			an2[in1]++;
		}
	}
	d1[0][0]=1;
	int i1,i2;
	double op,d1n=0,d2n=0;

	int in=3600;
	for(i=1;i<=in;i++){
		i1=i%2;
		for(j=0;j<=n;j++){
			d1[i1][j]=d2[i1][j]=0;
			for(k=an[j];k>=1;--k){
				if(an2[a[j][k][0]]!=0)
					d1[i1][j]+=d1[(i1+1)%2][a[j][k][0]]/(double)an2[a[j][k][0]];
			}
			for(k=an[j];k>=1;--k){
				if(an2[a[j][k][0]]!=0 && d1[i1][j]!=0)
					d2[i1][j]+=(a[j][k][1]+d2[(i1+1)%2][a[j][k][0]])*(d1[(i1+1)%2][a[j][k][0]]/(double)an2[a[j][k][0]])/d1[i1][j];
			}
		//	printf("%lf ",d2[i1][j]);
		}
		//getchar();
		la+=d1[i1][n]*d2[i1][n];
		d1n+=d1[i1][n];
		if(d2[i1][n]>d2n)
			d2n=d2[i1][n];
		if(i==in){
			//la+=(1-d1n)*d2n;
		}
	}
	printf("%lf",la);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1508 KB Output is correct
2 Correct 0 ms 1508 KB Output is correct
3 Correct 296 ms 1508 KB Output is correct
4 Correct 176 ms 1508 KB Output is correct
5 Correct 68 ms 1508 KB Output is correct
6 Correct 56 ms 1508 KB Output is correct
7 Correct 96 ms 1508 KB Output is correct
8 Correct 96 ms 1508 KB Output is correct
9 Incorrect 0 ms 1508 KB Output isn't correct
10 Halted 0 ms 0 KB -