結果

問題 No.506 限られたジャパリまん
ユーザー char134217728char134217728
提出日時 2017-08-11 06:55:54
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 599 bytes
コンパイル時間 59 ms
コンパイル使用メモリ 11,380 KB
実行使用メモリ 20,868 KB
最終ジャッジ日時 2023-09-10 12:55:23
合計ジャッジ時間 4,973 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,156 KB
testcase_01 AC 78 ms
15,352 KB
testcase_02 AC 78 ms
15,264 KB
testcase_03 AC 78 ms
15,052 KB
testcase_04 AC 88 ms
15,376 KB
testcase_05 AC 79 ms
15,044 KB
testcase_06 AC 80 ms
15,124 KB
testcase_07 AC 86 ms
15,336 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 432 ms
20,216 KB
testcase_12 WA -
testcase_13 AC 78 ms
15,128 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 89 ms
15,576 KB
testcase_18 WA -
testcase_19 AC 112 ms
16,252 KB
testcase_20 AC 164 ms
19,700 KB
testcase_21 AC 101 ms
16,060 KB
testcase_22 AC 183 ms
19,620 KB
testcase_23 AC 146 ms
18,696 KB
testcase_24 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

h, w, k, p = gets.split.map &:to_i
m = {}
f = k.times.map do |i|
  x, y, n = gets.split
  m[33 * x.to_i + y.to_i] = i
  n
end
comb = [*0...k].combination(p).to_a
ans = [0, []]
comb.each do |arr|
  a = []
  (h+1).times do |_h|
    a << []
    (w+1).times do |_w|
      i = m[33 * _h + _w]
      if i && !arr.index(i)
        a[_h][_w] = 0
        next
      end
      if _h == 0 || _w == 0
        a[_h][_w] = 1
      else
        a[_h][_w] = a[_h-1][_w] + a[_h][_w-1]
      end
    end
  end
  if ans[0] < a[h][w]
    ans = [a[h][w], arr]
  end
end
puts ans[0] % (10**9+7)
ans[1].each{|i| puts f[i]}
0