結果

問題 No.2064 Smallest Sequence on Grid
ユーザー るさるさ
提出日時 2021-09-29 00:37:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,321 ms / 3,000 ms
コード長 869 bytes
コンパイル時間 222 ms
コンパイル使用メモリ 82,408 KB
実行使用メモリ 181,812 KB
最終ジャッジ日時 2024-04-27 20:14:18
合計ジャッジ時間 22,842 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
53,020 KB
testcase_01 AC 33 ms
53,644 KB
testcase_02 AC 36 ms
53,352 KB
testcase_03 AC 34 ms
53,052 KB
testcase_04 AC 35 ms
52,208 KB
testcase_05 AC 33 ms
53,480 KB
testcase_06 AC 37 ms
53,196 KB
testcase_07 AC 34 ms
53,800 KB
testcase_08 AC 38 ms
58,964 KB
testcase_09 AC 37 ms
59,248 KB
testcase_10 AC 39 ms
60,736 KB
testcase_11 AC 41 ms
59,800 KB
testcase_12 AC 40 ms
59,712 KB
testcase_13 AC 43 ms
63,340 KB
testcase_14 AC 46 ms
64,420 KB
testcase_15 AC 49 ms
65,908 KB
testcase_16 AC 45 ms
63,560 KB
testcase_17 AC 607 ms
165,236 KB
testcase_18 AC 594 ms
165,640 KB
testcase_19 AC 567 ms
165,644 KB
testcase_20 AC 1,694 ms
176,228 KB
testcase_21 AC 1,792 ms
176,968 KB
testcase_22 AC 1,373 ms
172,900 KB
testcase_23 AC 1,392 ms
173,260 KB
testcase_24 AC 1,415 ms
173,664 KB
testcase_25 AC 1,356 ms
173,412 KB
testcase_26 AC 2,198 ms
181,748 KB
testcase_27 AC 2,321 ms
181,812 KB
testcase_28 AC 580 ms
165,544 KB
testcase_29 AC 1,880 ms
161,908 KB
testcase_30 AC 597 ms
157,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

h,w = map(int, input().split())
Alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
alpha = "abcdefghijklmnopqrstuvwxyz"
Dict_alpha = {}
dict_alpha = {}
for i in range(26):
    Dict_alpha[Alpha[i]] = i
    dict_alpha[alpha[i]] = i
Dec = lambda x:Dict_alpha[x]
dec = lambda x:dict_alpha[x]
s = [list(map(dec, list(input()))) + [26] for i in range(h)] + [[26] * w]
#print(s)
st = {(0,0)}
ans = [alpha[s[0][0]]]
for i in range(h+w-2):
    mn = 100
    nst = set()
    for jx, jy in st:
        t = s[jx+1][jy]
        if t == mn:
            nst.add((jx+1, jy))
        elif t < mn:
            mn = t
            nst = {(jx+1, jy)}
            
        t = s[jx][jy+1]
        if t == mn:
            nst.add((jx, jy+1))
        elif t < mn:
            mn = t
            nst = {(jx, jy+1)}
    st = nst
    #print(len(st))
    #print(mn)
    ans.append(alpha[mn])

print("".join(ans))
0