結果

問題 No.2064 Smallest Sequence on Grid
ユーザー 👑 H20H20
提出日時 2022-09-02 22:23:07
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 713 bytes
コンパイル時間 218 ms
コンパイル使用メモリ 82,020 KB
実行使用メモリ 442,796 KB
最終ジャッジ日時 2024-04-27 21:58:00
合計ジャッジ時間 19,578 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
53,504 KB
testcase_01 AC 30 ms
54,088 KB
testcase_02 AC 31 ms
52,268 KB
testcase_03 AC 31 ms
52,368 KB
testcase_04 AC 31 ms
53,376 KB
testcase_05 AC 31 ms
52,724 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 TLE -
testcase_27 TLE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W = map(int, input().split())
S = []
for _ in range(H):
    S.append(list(input()+'~'))
S.append(list('~'*W))

pos = set()
pos.add((0,0))
ANS = [S[0][0]]

while len(ANS)<H+W-1:
    alphabet = 'z'
    nextPos = set()
    for xy in list(pos):
        x,y = xy
        if S[x+1][y]==alphabet:
            nextPos.add((x+1,y))
        elif S[x+1][y]<alphabet:
            alphabet = S[x+1][y]
            nextPos = [(x+1,y)]
        if not (x,y+1) in nextPos:
            if S[x][y+1]==alphabet:
                nextPos.add((x,y+1))
            elif S[x][y+1]<alphabet:
                alphabet = S[x][y+1]
                nextPos = [(x,y+1)]
    ANS.append(alphabet)
    pos = nextPos
print(''.join(map(str, ANS)))
0