結果

問題 No.2064 Smallest Sequence on Grid
ユーザー titiatitia
提出日時 2022-09-09 07:30:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,140 ms / 3,000 ms
コード長 507 bytes
コンパイル時間 434 ms
コンパイル使用メモリ 86,964 KB
実行使用メモリ 102,888 KB
最終ジャッジ日時 2023-08-16 15:15:12
合計ジャッジ時間 19,538 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,260 KB
testcase_01 AC 75 ms
71,324 KB
testcase_02 AC 73 ms
70,864 KB
testcase_03 AC 71 ms
70,972 KB
testcase_04 AC 72 ms
71,256 KB
testcase_05 AC 70 ms
71,236 KB
testcase_06 AC 69 ms
70,804 KB
testcase_07 AC 70 ms
71,224 KB
testcase_08 AC 77 ms
75,820 KB
testcase_09 AC 76 ms
75,320 KB
testcase_10 AC 78 ms
76,096 KB
testcase_11 AC 79 ms
76,420 KB
testcase_12 AC 83 ms
76,432 KB
testcase_13 AC 89 ms
76,272 KB
testcase_14 AC 89 ms
76,196 KB
testcase_15 AC 84 ms
76,584 KB
testcase_16 AC 84 ms
76,268 KB
testcase_17 AC 146 ms
86,464 KB
testcase_18 AC 143 ms
86,468 KB
testcase_19 AC 147 ms
86,480 KB
testcase_20 AC 1,650 ms
99,804 KB
testcase_21 AC 1,824 ms
102,108 KB
testcase_22 AC 1,189 ms
95,172 KB
testcase_23 AC 1,156 ms
94,676 KB
testcase_24 AC 1,154 ms
94,736 KB
testcase_25 AC 1,169 ms
95,356 KB
testcase_26 AC 2,140 ms
102,888 KB
testcase_27 AC 2,119 ms
102,676 KB
testcase_28 AC 145 ms
86,088 KB
testcase_29 AC 1,906 ms
101,324 KB
testcase_30 AC 138 ms
85,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

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

Q=[(0,0)]

ANS=[S[0][0]]

while Q:
    D=[set() for i in range(26)]
    
    while Q:
        x,y=Q.pop()

        for z,w in [(x+1,y),(x,y+1)]:
            if 0<=z<H and 0<=w<W:
                k=S[z][w]
                D[ord(k)-97].add((z,w))

    for i in range(26):
        if D[i]!=set():
            ANS.append(chr(i+97))
            break
            
    Q=D[i]
        
print("".join(ANS))  
0