結果

問題 No.496 ワープクリスタル (給料日前編)
ユーザー smz_8110smz_8110
提出日時 2017-04-05 15:34:41
言語 Ruby
(3.3.0)
結果
AC  
実行時間 297 ms / 2,000 ms
コード長 486 bytes
コンパイル時間 129 ms
コンパイル使用メモリ 11,560 KB
実行使用メモリ 15,588 KB
最終ジャッジ日時 2023-09-22 20:08:17
合計ジャッジ時間 4,362 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,148 KB
testcase_01 AC 78 ms
15,144 KB
testcase_02 AC 79 ms
15,248 KB
testcase_03 AC 78 ms
15,176 KB
testcase_04 AC 78 ms
15,036 KB
testcase_05 AC 80 ms
15,276 KB
testcase_06 AC 82 ms
15,588 KB
testcase_07 AC 79 ms
15,272 KB
testcase_08 AC 297 ms
15,388 KB
testcase_09 AC 82 ms
15,512 KB
testcase_10 AC 80 ms
15,336 KB
testcase_11 AC 82 ms
15,036 KB
testcase_12 AC 85 ms
15,244 KB
testcase_13 AC 89 ms
15,152 KB
testcase_14 AC 80 ms
15,068 KB
testcase_15 AC 85 ms
15,148 KB
testcase_16 AC 84 ms
15,244 KB
testcase_17 AC 90 ms
15,148 KB
testcase_18 AC 83 ms
15,320 KB
testcase_19 AC 98 ms
15,296 KB
testcase_20 AC 84 ms
15,040 KB
testcase_21 AC 82 ms
15,124 KB
testcase_22 AC 208 ms
15,524 KB
testcase_23 AC 248 ms
15,404 KB
testcase_24 AC 170 ms
15,432 KB
testcase_25 AC 141 ms
15,492 KB
testcase_26 AC 175 ms
15,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

Gx,Gy,N,F=gets.split.map &:to_i
M=N.times.map{gets.split.map(&:to_i)}
a=(Gy+1).times.map{|y|(Gx+1).times.map{|x|y*F+x*F}}
e=[[0,0,0]]
M.each{|c|
  h={}
  e.each{|v|
    x,y,z=v[0]+c[0],v[1]+c[1],v[2]+c[2]
    next if x>Gx||y>Gy
    if a[y][x]>z
      h[y*1000+x]=[x,y,z]
      (Gy-y+1).times{|ny|
        (Gx-x+1).times{|nx|
          nz=z+nx*F+ny*F
          if a[y+ny][x+nx]>nz
            a[y+ny][x+nx]=nz
          end
        }
      }
    end
  }
  e.concat h.values
}
p a[Gy][Gx]
0