結果

問題 No.2064 Smallest Sequence on Grid
ユーザー ああいいああいい
提出日時 2022-09-04 11:05:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,790 ms / 3,000 ms
コード長 590 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 104,580 KB
最終ジャッジ日時 2024-04-29 10:19:25
合計ジャッジ時間 16,209 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
51,968 KB
testcase_01 AC 39 ms
51,840 KB
testcase_02 AC 39 ms
51,840 KB
testcase_03 AC 39 ms
51,968 KB
testcase_04 AC 39 ms
51,968 KB
testcase_05 AC 38 ms
52,096 KB
testcase_06 AC 39 ms
52,352 KB
testcase_07 AC 40 ms
51,840 KB
testcase_08 AC 41 ms
52,352 KB
testcase_09 AC 39 ms
52,352 KB
testcase_10 AC 40 ms
52,736 KB
testcase_11 AC 44 ms
52,964 KB
testcase_12 AC 41 ms
52,608 KB
testcase_13 AC 51 ms
61,824 KB
testcase_14 AC 54 ms
63,508 KB
testcase_15 AC 53 ms
62,976 KB
testcase_16 AC 54 ms
63,180 KB
testcase_17 AC 136 ms
84,708 KB
testcase_18 AC 126 ms
84,508 KB
testcase_19 AC 130 ms
85,012 KB
testcase_20 AC 1,497 ms
100,272 KB
testcase_21 AC 1,619 ms
101,960 KB
testcase_22 AC 1,087 ms
95,136 KB
testcase_23 AC 968 ms
92,788 KB
testcase_24 AC 966 ms
93,168 KB
testcase_25 AC 970 ms
93,144 KB
testcase_26 AC 1,790 ms
100,608 KB
testcase_27 AC 1,767 ms
100,688 KB
testcase_28 AC 124 ms
84,348 KB
testcase_29 AC 1,763 ms
104,580 KB
testcase_30 AC 135 ms
84,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W = map(int,input().split())
S = [input() for _ in range(H)]

ans = []
s = set()
s.add((0,0))

ans.append(S[0][0])
for _ in range(H + W - 2):
    nx = set()
    c = "z"
    for x,y in s:
        if x + 1 < H:
            u = S[x + 1][y]
            if u < c:
                c = u
        if y + 1 < W:
            u = S[x][y + 1]
            if u < c:
                c = u
    ans.append(c)
    for x,y in s:
        if x + 1 < H and S[x + 1][y] == c:
            nx.add((x + 1,y))
        if y + 1 < W and S[x][y + 1] == c:
            nx.add((x,y + 1))
    s = nx
print("".join(ans))
0