結果

問題 No.298 話の伝達
ユーザー yosupotyosupot
提出日時 2015-11-06 22:48:51
言語 D
(dmd 2.107.1)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 867 bytes
コンパイル時間 2,061 ms
コンパイル使用メモリ 159,072 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-09-02 20:22:03
合計ジャッジ時間 3,355 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,368 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 1 ms
4,368 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,368 KB
testcase_06 WA -
testcase_07 AC 1 ms
4,368 KB
testcase_08 AC 1 ms
4,368 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 1 ms
4,368 KB
testcase_12 AC 1 ms
4,372 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
4,368 KB
testcase_16 AC 1 ms
4,368 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.conv;
import std.algorithm, std.range, std.random;
import std.string, std.array, std.container, std.bigint;
import std.typecons;


int main() {
	int n, m;
	readf("%d %d\n", &n, &m);

	alias E = Tuple!(int, int, double);
	E[] g;

	foreach (i; 0..m) {
		int a, b; double c;
		readf("%d %d %f\n", &a, &b, &c);
		g ~= tuple(a, b, c);
	}
	double[] res = new double[](n);
	bool[] used = new bool[](n);
	res[0] = 1; used[0] = true;
	foreach (_ ; 0..2*n) {
		foreach (i; 0..n) {
			if (used[i]) continue;
			bool f = true;
			double sm = 1;
			foreach (e; g) {
				if (e[1] != i) continue;
				if (used[e[0]] == false) {
					f = false;
					break;
				}
				sm *= (1 - res[e[0]]*e[2] / 100.0);
			}
			if (!f) continue;
			res[i] = 1-sm;
			used[i] = true;
		}
	}
	if (used[n-1]) {
		writef("%.20f\n", res[n-1]);
	} else {
		writeln(0);
	}
	return 0;
}
0