結果

問題 No.2064 Smallest Sequence on Grid
ユーザー kozykozy
提出日時 2022-09-02 22:15:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,400 ms / 3,000 ms
コード長 488 bytes
コンパイル時間 1,832 ms
コンパイル使用メモリ 86,948 KB
実行使用メモリ 120,896 KB
最終ジャッジ日時 2023-08-10 04:30:17
合計ジャッジ時間 21,331 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,204 KB
testcase_01 AC 64 ms
71,316 KB
testcase_02 AC 67 ms
71,484 KB
testcase_03 AC 65 ms
71,220 KB
testcase_04 AC 65 ms
71,252 KB
testcase_05 AC 69 ms
71,156 KB
testcase_06 AC 66 ms
71,324 KB
testcase_07 AC 67 ms
71,188 KB
testcase_08 AC 70 ms
71,192 KB
testcase_09 AC 68 ms
71,064 KB
testcase_10 AC 70 ms
71,540 KB
testcase_11 AC 81 ms
76,328 KB
testcase_12 AC 73 ms
76,196 KB
testcase_13 AC 77 ms
76,400 KB
testcase_14 AC 79 ms
76,680 KB
testcase_15 AC 76 ms
76,440 KB
testcase_16 AC 79 ms
76,420 KB
testcase_17 AC 146 ms
86,752 KB
testcase_18 AC 149 ms
86,752 KB
testcase_19 AC 151 ms
87,068 KB
testcase_20 AC 1,668 ms
104,752 KB
testcase_21 AC 1,744 ms
107,996 KB
testcase_22 AC 1,182 ms
97,152 KB
testcase_23 AC 1,197 ms
103,780 KB
testcase_24 AC 1,246 ms
103,856 KB
testcase_25 AC 1,207 ms
103,824 KB
testcase_26 AC 2,340 ms
120,896 KB
testcase_27 AC 2,400 ms
120,648 KB
testcase_28 AC 151 ms
86,848 KB
testcase_29 AC 2,046 ms
110,900 KB
testcase_30 AC 151 ms
85,420 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