結果
問題 | No.298 話の伝達 |
ユーザー |
|
提出日時 | 2018-06-01 12:50:22 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 770 ms / 5,000 ms |
コード長 | 972 bytes |
コンパイル時間 | 2,418 ms |
コンパイル使用メモリ | 161,684 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-13 01:05:40 |
合計ジャッジ時間 | 5,372 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, std.bitmanip; void main() { auto s = readln.split.map!(to!int); auto N = s[0]; auto M = s[1]; auto G = new Tuple!(int, real)[][](N); foreach (_; 0..M) { s = readln.split.map!(to!int); G[s[1]] ~= tuple(s[0], s[2]/100.0L); } real ans = 0; foreach (mask; 0..(1<<N)) { if ((mask & 1) == 0 || ((mask >> (N-1)) & 1) == 0) continue; real tmp = 1; foreach (u; 1..N) { real tmp2 = 1; foreach (to; G[u]) { int v = to[0]; real p = to[1]; tmp2 *= ((mask >> v) & 1) ? (1-p) : 1; } tmp2 = ((mask >> u) & 1) ? (1 - tmp2) : tmp2; tmp *= tmp2; } ans += tmp; } writefln("%.09f", ans); }