結果
問題 |
No.2064 Smallest Sequence on Grid
|
ユーザー |
|
提出日時 | 2022-09-18 23:20:42 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 651 bytes |
コンパイル時間 | 396 ms |
コンパイル使用メモリ | 82,600 KB |
実行使用メモリ | 849,660 KB |
最終ジャッジ日時 | 2024-12-22 01:50:14 |
合計ジャッジ時間 | 63,663 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 5 RE * 5 TLE * 6 MLE * 13 |
ソースコード
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" 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 and s[i][j+1] == mn: new.append((i,j+1)) elif j == w-1 and 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 if l == [(h-1, w-1)]: break print(ans)