結果

問題 No.2064 Smallest Sequence on Grid
ユーザー flygonflygon
提出日時 2022-09-18 23:20:42
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 651 bytes
コンパイル時間 400 ms
コンパイル使用メモリ 87,096 KB
実行使用メモリ 848,840 KB
最終ジャッジ日時 2023-08-23 18:24:59
合計ジャッジ時間 6,872 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,180 KB
testcase_01 AC 70 ms
71,316 KB
testcase_02 RE -
testcase_03 AC 71 ms
71,464 KB
testcase_04 AC 68 ms
71,444 KB
testcase_05 AC 68 ms
71,336 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 70 ms
71,260 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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
  


     
0