結果

問題 No.2064 Smallest Sequence on Grid
ユーザー kozykozy
提出日時 2022-09-02 22:15:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,901 ms / 3,000 ms
コード長 488 bytes
コンパイル時間 134 ms
コンパイル使用メモリ 82,372 KB
実行使用メモリ 119,512 KB
最終ジャッジ日時 2024-04-27 21:50:47
合計ジャッジ時間 15,226 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
52,304 KB
testcase_01 AC 32 ms
53,368 KB
testcase_02 AC 31 ms
51,996 KB
testcase_03 AC 32 ms
52,504 KB
testcase_04 AC 32 ms
52,468 KB
testcase_05 AC 31 ms
52,180 KB
testcase_06 AC 32 ms
53,664 KB
testcase_07 AC 31 ms
52,268 KB
testcase_08 AC 33 ms
53,500 KB
testcase_09 AC 33 ms
52,964 KB
testcase_10 AC 33 ms
53,412 KB
testcase_11 AC 39 ms
61,616 KB
testcase_12 AC 37 ms
61,696 KB
testcase_13 AC 42 ms
64,336 KB
testcase_14 AC 45 ms
66,192 KB
testcase_15 AC 44 ms
64,156 KB
testcase_16 AC 44 ms
65,152 KB
testcase_17 AC 106 ms
84,788 KB
testcase_18 AC 106 ms
84,596 KB
testcase_19 AC 108 ms
84,556 KB
testcase_20 AC 1,329 ms
103,480 KB
testcase_21 AC 1,431 ms
106,728 KB
testcase_22 AC 949 ms
95,572 KB
testcase_23 AC 1,019 ms
102,452 KB
testcase_24 AC 1,027 ms
102,400 KB
testcase_25 AC 974 ms
102,676 KB
testcase_26 AC 1,888 ms
119,512 KB
testcase_27 AC 1,901 ms
119,444 KB
testcase_28 AC 110 ms
84,928 KB
testcase_29 AC 1,551 ms
108,812 KB
testcase_30 AC 104 ms
84,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W=map(int,input().split())
L=list()
for i in range(H):
  s=input()
  L.append(s)
ans=list()
ans.append(L[0][0])
A=[0,0]
def f(x,y):
  if 0<=x<H and 0<=y<W:
    return True
  return False
stack=[[0,0]]
for i in range(H+W-2):
  s="z"
  S=set()
  while stack:
    a,b=stack.pop()
    for da,db in [[1,0],[0,1]]:
      if f(a+da,b+db):
        s=min(s,L[a+da][b+db])
        S.add((a+da,b+db))
  for a,b in S:
    if L[a][b]==s:
      stack.append((a,b))
  ans.append(s)
print("".join(ans))
0