結果

問題 No.298 話の伝達
ユーザー sugim48sugim48
提出日時 2015-11-07 00:00:05
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 800 bytes
コンパイル時間 684 ms
コンパイル使用メモリ 80,880 KB
実行使用メモリ 4,480 KB
最終ジャッジ日時 2023-10-11 14:34:15
合計ジャッジ時間 2,290 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

using namespace std;
#include <algorithm>
#include <iostream>
#include <random>
#include <string>
#include <fstream>
#include <vector>
#include <climits>

typedef long long ll;
ll INF = LLONG_MAX / 2;

int main() {
	int N, M; cin >> N >> M;
	vector<int> A(M), B(M), C(M);
	vector<double> c(M);
	for (int i = 0; i < M; i++) {
		cin >> A[i] >> B[i] >> C[i];
		c[i] = C[i] / 100.0;
	}
	double sum = 0;
	for (int S = 0; S < 1<<(N - 2); S++) {
		vector<bool> a(N);
		a[0] = a[N - 1] = true;
		for (int u = 0; u < N - 2; u++)
			a[u + 1] = S>>u & 1;
		vector<double> p(N, 1), q(N, 1);
		for (int i = 0; i < M; i++)
			if (a[A[i]]) {
				p[B[i]] *= c[i];
				q[B[i]] *= 1 - c[i];
			}
		double x = 1;
		for (int u = 1; u < N; u++)
			x *= 1 - (a[u] ? q[u] : p[u]);
		sum += x;
	}
	printf("%.10f\n", sum);
}
0