結果

問題 No.298 話の伝達
ユーザー けーけー
提出日時 2015-11-07 00:17:38
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 845 bytes
コンパイル時間 632 ms
コンパイル使用メモリ 65,644 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-11 14:37:20
合計ジャッジ時間 1,426 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<string>
#include<list>
#include<map>
#include<vector>
#include<stack>
#include<cstdint>
#include<sstream>
#include<numeric>
#define INT int
struct Group {
	INT a;
	INT b;
	INT c;
};
using namespace std;
int main() {
	INT n, m;
	INT i, j, k;
	Group gr[190];
	double pr[20];
	fill(pr, pr + 20, 1000.0);
	cin >> n >> m;
	for (i = 0; i < m; i++) {
		auto &z = gr[i];
		cin >> z.a >> z.b >> z.c;
	}
	pr[0] = 1.0;
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			if (pr[j] == 1000.0) {
				bool f = true;
				double t = 0.0;
				for (k = 0; k < m; k++) {
					if (gr[k].b == j) {
						if (pr[gr[k].a] != 1000.0) {
							t +=(1.0-t)*pr[gr[k].a] * ((double)gr[k].c / 100.0);
						}
						else {
							f = false;
						}
					}
				}
				if (f) {
					pr[j] = t;
				}
			}
		}
	}
	printf("%.14f\n", pr[n - 1]);
}
0