답안 #3497

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
3497 2013-08-31T06:11:41 Z pichulia Following Flow (kriii1_F) C++
0 / 1
40 ms 1308 KB
#include<stdio.h>

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

double d[3][35][250];
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);
		a[in1][++an[in1]][0]=in2;
		a[in1][an[in1]][1]=in3;
	}
	d[0][0][0]=1;
	int i1,i2;
	double op;
	for(i=0;i<=25000;++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;
	}
	printf("%lf",la);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1308 KB Output is correct
2 Correct 4 ms 1308 KB Output is correct
3 Incorrect 40 ms 1308 KB Output isn't correct
4 Halted 0 ms 0 KB -