結果

問題 No.298 話の伝達
ユーザー cielciel
提出日時 2015-11-09 21:24:48
言語 Crystal
(1.11.2)
結果
AC  
実行時間 545 ms / 5,000 ms
コード長 411 bytes
コンパイル時間 19,113 ms
コンパイル使用メモリ 261,988 KB
実行使用メモリ 5,296 KB
最終ジャッジ日時 2023-09-13 09:00:50
合計ジャッジ時間 22,506 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,448 KB
testcase_02 AC 3 ms
4,428 KB
testcase_03 AC 2 ms
4,412 KB
testcase_04 AC 2 ms
4,448 KB
testcase_05 AC 255 ms
5,228 KB
testcase_06 AC 4 ms
4,844 KB
testcase_07 AC 3 ms
4,412 KB
testcase_08 AC 2 ms
4,468 KB
testcase_09 AC 4 ms
4,856 KB
testcase_10 AC 11 ms
4,828 KB
testcase_11 AC 319 ms
4,848 KB
testcase_12 AC 157 ms
4,788 KB
testcase_13 AC 357 ms
5,172 KB
testcase_14 AC 163 ms
5,296 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 545 ms
5,108 KB
testcase_17 AC 10 ms
4,920 KB
testcase_18 AC 122 ms
5,168 KB
testcase_19 AC 3 ms
4,424 KB
testcase_20 AC 268 ms
5,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m=gets.not_nil!.split.map(&.to_i)
G={} of Int32 => Array(Tuple(Int32,Float64))
m.times{
	a,b,c=gets.not_nil!.split.map(&.to_i)
	G[b]||=[] of Tuple(Int32,Float64)
	G[b]<<{a,c/100.0}
}
r=0
(1<<(n-2)).times{|i|
	a=[0.0]+[1.0]*(n-1)
	n.times{|j|G[j].each{|e|a[j]*=1-e[1] if e[0]==0||e[0]==n-1||(i&(1<<e[0]-1))!=0} if G.has_key?(j)}
	r0=1
	n.times{|j|r0*=j==0||j==n-1||(i&(1<<j-1))!=0 ? 1-a[j] : a[j]}
	r+=r0
}
p r
0