結果

問題 No.556 仁義なきサルたち
ユーザー letrangerjpletrangerjp
提出日時 2017-11-02 07:13:34
言語 Ruby
(3.3.0)
結果
AC  
実行時間 442 ms / 2,000 ms
コード長 172 bytes
コンパイル時間 200 ms
コンパイル使用メモリ 11,384 KB
実行使用メモリ 18,624 KB
最終ジャッジ日時 2023-08-14 14:25:06
合計ジャッジ時間 5,335 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,252 KB
testcase_01 AC 80 ms
15,108 KB
testcase_02 AC 79 ms
15,076 KB
testcase_03 AC 79 ms
15,252 KB
testcase_04 AC 80 ms
15,124 KB
testcase_05 AC 84 ms
15,440 KB
testcase_06 AC 89 ms
15,480 KB
testcase_07 AC 88 ms
15,640 KB
testcase_08 AC 87 ms
15,680 KB
testcase_09 AC 89 ms
16,092 KB
testcase_10 AC 102 ms
16,880 KB
testcase_11 AC 112 ms
17,960 KB
testcase_12 AC 112 ms
17,892 KB
testcase_13 AC 93 ms
16,432 KB
testcase_14 AC 175 ms
18,200 KB
testcase_15 AC 217 ms
18,240 KB
testcase_16 AC 179 ms
18,172 KB
testcase_17 AC 269 ms
18,624 KB
testcase_18 AC 419 ms
18,480 KB
testcase_19 AC 441 ms
18,504 KB
testcase_20 AC 442 ms
18,592 KB
testcase_21 AC 440 ms
18,500 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:7: warning: `*' interpreted as argument prefix
Main.rb:2: warning: assigned but unused variable - z
Syntax OK

ソースコード

diff #

n=*0..N=gets.to_i
z=[1]*-~N
r=->i{i==n[i]?i:r[n[i]]}
$<.map{|s|eval"z[c=r[%d]]<z[d=r[%d]]||z[c]==z[d]&&c>d||(c,d=d,c)
n[c]=n[d]
c==d||z[d]+=z[c]"%s.split}
p *(1..N).map(&r)
0