답안 #3803

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
3803 2013-08-31T08:26:00 Z qja0950 Following Flow (kriii1_F) C++
0 / 1
40 ms 1220 KB
#include <stdio.h>
#include <vector>
using namespace std;

typedef pair<int,int> P;

vector<P> line[32];

int n, m;
//int line[34][34][3];
int x, y, z, cnt, now, how;
double plus[54][34], ans=0;
int times;
int main() {
//	freopen("input.txt", "r", stdin);
	scanf("%d %d", &n, &m);
	int i, j;
P temp;
	for(i=1; i<=m; i++) {
		scanf("%d %d %d", &x, &y, &z);
		
		temp.first=y;temp.second=z;
		line[x].push_back(temp);
/*
		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<=8000) {
		for(i=0; i<n; i++) {
			how=line[i].size();
			if(how==0 || plus[times%51][i]==0) continue;
			for(j=0; j<how; j++) {
				plus[(times+line[i][j].second)%51][line[i][j].first]+=((double)1/(double)how)*plus[times%51][i];
			}
			plus[times%51][i]=0;
		}
		if(plus[times%51][n]!=0) {
			ans+=(plus[times%51][n]*(double)times);
			plus[times%51][n]=0;
		}
		times++;
	}
	printf("%.9lf\n", ans);
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1220 KB Output is correct
2 Correct 0 ms 1220 KB Output is correct
3 Correct 20 ms 1220 KB Output is correct
4 Correct 32 ms 1220 KB Output is correct
5 Correct 28 ms 1220 KB Output is correct
6 Correct 20 ms 1220 KB Output is correct
7 Correct 40 ms 1220 KB Output is correct
8 Incorrect 40 ms 1220 KB Output isn't correct
9 Halted 0 ms 0 KB -