結果

問題 No.2064 Smallest Sequence on Grid
ユーザー first_vilfirst_vil
提出日時 2022-09-02 21:41:16
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,049 bytes
コンパイル時間 144 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 571,564 KB
最終ジャッジ日時 2024-04-27 21:10:46
合計ジャッジ時間 15,605 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 AC 35 ms
52,784 KB
testcase_02 AC 34 ms
52,388 KB
testcase_03 AC 33 ms
52,464 KB
testcase_04 AC 33 ms
53,284 KB
testcase_05 AC 33 ms
52,616 KB
testcase_06 AC 34 ms
54,076 KB
testcase_07 AC 33 ms
53,264 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 MLE -
testcase_18 MLE -
testcase_19 MLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
testcase_27 TLE -
testcase_28 MLE -
testcase_29 AC 2,686 ms
497,556 KB
testcase_30 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
import sys

int1 = lambda x: int(x) - 1

# input = lambda: sys.stdin.buffer.readline()
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
i1 = lambda: int1(input())
mi = lambda: map(int, input().split())
mi1 = lambda: map(int1, input().split())
li = lambda: list(mi())
li1 = lambda: list(mi1())
lli = lambda n: [li() for _ in range(n)]

INF = float("inf")
mod = int(1e9 + 7)
# mod = 998244353

h, w = mi()
s = [input() for i in range(h)]
ans = [s[0][0]]
e = chr(ord("z") + 1)
d = [list() for i in range(h + w - 1)]
for y in range(h):
    for x in range(w):
        d[y + x].append((y, x))
f = [[False] * w for i in range(h)]
f[0][0] = True
for i in range(h + w - 2):
    mn = e
    for y, x in d[i]:
        if not f[y][x]:
            continue
        if y + 1 < h and mn > s[y + 1][x]:
            mn = s[y + 1][x]
        if x + 1 < w and mn > s[y][x + 1]:
            mn = s[y][x + 1]
    ans.append(mn)
    for y, x in d[i + 1]:
        if s[y][x] == mn:
            f[y][x] = True
print("".join(ans))
0