結果

問題 No.298 話の伝達
ユーザー cielciel
提出日時 2015-11-09 21:12:40
言語 Ruby
(3.3.0)
結果
RE  
実行時間 -
コード長 355 bytes
コンパイル時間 75 ms
コンパイル使用メモリ 11,540 KB
実行使用メモリ 18,404 KB
最終ジャッジ日時 2023-10-11 15:27:14
合計ジャッジ時間 23,309 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
15,316 KB
testcase_01 AC 81 ms
15,112 KB
testcase_02 AC 82 ms
15,168 KB
testcase_03 AC 83 ms
15,216 KB
testcase_04 AC 82 ms
15,160 KB
testcase_05 AC 3,396 ms
18,304 KB
testcase_06 RE -
testcase_07 AC 82 ms
15,156 KB
testcase_08 AC 82 ms
15,112 KB
testcase_09 RE -
testcase_10 AC 167 ms
16,680 KB
testcase_11 AC 3,883 ms
18,404 KB
testcase_12 AC 1,797 ms
17,644 KB
testcase_13 AC 4,284 ms
18,396 KB
testcase_14 AC 1,960 ms
17,624 KB
testcase_15 AC 83 ms
15,052 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#!/usr/bin/ruby
N,M=gets.split.map(&:to_i)
G=Hash.new{|h,k|h[k]=[]}
$<.each{|e|
	a,b,c=e.split.map(&:to_i)
	raise if a>=b
	G[b]<<[a,c/100.0]
}
(p 0;exit)if N==1	
r=0
(1<<(N-2)).times{|i|
	a=[0]+[1]*(N-1)
	N.times{|j|
		G[j].each{|x,y|a[j]*=1-y if x==0||x==N-1||i[x-1]==1}
	}
	r0=1
	N.times{|j|
		r0*=j==0||j==N-1||i[j-1]==1 ? 1-a[j] : a[j]
	}
	r+=r0
}
p r
0