結果
問題 | No.2064 Smallest Sequence on Grid |
ユーザー | flygon |
提出日時 | 2022-09-18 23:24:42 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 664 bytes |
コンパイル時間 | 634 ms |
コンパイル使用メモリ | 87,120 KB |
実行使用メモリ | 848,888 KB |
最終ジャッジ日時 | 2023-08-23 18:25:19 |
合計ジャッジ時間 | 6,599 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 71 ms
71,060 KB |
testcase_01 | AC | 70 ms
71,524 KB |
testcase_02 | AC | 71 ms
71,332 KB |
testcase_03 | AC | 69 ms
71,188 KB |
testcase_04 | AC | 71 ms
71,260 KB |
testcase_05 | AC | 71 ms
71,360 KB |
testcase_06 | AC | 70 ms
71,268 KB |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | AC | 70 ms
71,228 KB |
testcase_10 | RE | - |
testcase_11 | MLE | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
ソースコード
h,w = map(int,input().split()) s = [input() for i in range(h)] now = 0 l = [(0,0)] ans = s[0][0] while now < h+w-1: new = [] mn = "z" if l == [(h-1, w-1)]: break for i,j in l: if i == h-1: mn = min(mn, s[i][j+1]) elif j == w-1: mn = min(mn, s[i+1][j]) else: mn = min(mn, s[i][j+1], s[i+1][j]) for i,j in l: if i == h-1: if s[i][j+1] == mn: new.append((i,j+1)) elif j == w-1: if s[i+1][j] == mn: new.append((i+1,j)) else: if s[i][j+1] == mn: new.append((i,j+1)) if s[i+1][j] == mn: new.append((i+1,j)) l = new now += 1 ans += mn print(ans)