結果

問題 No.2064 Smallest Sequence on Grid
ユーザー rlangevinrlangevin
提出日時 2023-01-21 01:26:09
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 831 bytes
コンパイル時間 2,239 ms
コンパイル使用メモリ 85,860 KB
実行使用メモリ 842,376 KB
最終ジャッジ日時 2023-09-05 17:33:10
合計ジャッジ時間 10,623 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,060 KB
testcase_01 AC 81 ms
71,300 KB
testcase_02 AC 81 ms
71,100 KB
testcase_03 AC 80 ms
71,512 KB
testcase_04 AC 78 ms
71,288 KB
testcase_05 AC 78 ms
71,500 KB
testcase_06 AC 77 ms
71,232 KB
testcase_07 AC 77 ms
71,064 KB
testcase_08 AC 87 ms
76,092 KB
testcase_09 AC 83 ms
75,952 KB
testcase_10 AC 88 ms
76,172 KB
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 #

import sys
readline = sys.stdin.readline

def alp_to_num(cha):
    num = ord(cha) - ord("a")
    return num


H, W = map(int, readline().split())
S = []
for i in range(H):
    L = list(readline().rstrip())
    L = list(map(alp_to_num, L))
    S.append(L)
    
x, y = 0, 0
pre = [[] for i in range(26)]
pre[S[0][0]].append((x, y))
dx, dy = [1, 0], [0, 1]
ans = []
for i in range(H + W - 1):
    dp = [[] for i in range(26)]
    for i, lst in enumerate(pre):
        if lst:
            ans.append(chr(i + ord("a")))
            for nx, ny in lst:
                for k in range(2):
                    x = nx + dx[k]
                    y = ny + dy[k]
                    if x == H or y == W:
                        continue
                    dp[S[x][y]].append((x, y))
            break
    dp, pre = pre, dp
print(*ans, sep="")
0