結果

問題 No.2064 Smallest Sequence on Grid
ユーザー SidewaysOwlSidewaysOwl
提出日時 2022-09-03 18:30:46
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 708 bytes
コンパイル時間 347 ms
コンパイル使用メモリ 82,260 KB
実行使用メモリ 844,360 KB
最終ジャッジ日時 2024-04-28 15:54:21
合計ジャッジ時間 29,123 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,680 KB
testcase_01 AC 35 ms
53,024 KB
testcase_02 AC 33 ms
52,204 KB
testcase_03 AC 31 ms
52,268 KB
testcase_04 AC 34 ms
52,336 KB
testcase_05 AC 36 ms
53,080 KB
testcase_06 WA -
testcase_07 WA -
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 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 MLE -
testcase_23 MLE -
testcase_24 MLE -
testcase_25 MLE -
testcase_26 MLE -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

h,w = map(int,input().split())
s = [list(input()) for _ in range(h)]
vis = [[-1] * w for _ in range(h)]
vis[0][0] = 0
vecs = [(0,1),(1,0)]
mark = s[0][0]
ans = []
for n in range(h+w):
    n_mark = '{'
    for i in range(n+1):
        j = n-i
        if not (0 <= i <= h-1 and 0 <= j <= w-1):continue
        if s[i][j] == mark and vis[i][j] == 0:
            vis[i][j] = 1
            ans.append(mark)
            for vi,vj in vecs:
                ni,nj = i + vi,j + vj
                if not (0 <= ni <= h-1 and 0 <= nj <= w-1):continue
                vis[ni][nj] = 0
                if n_mark > s[ni][nj]:
                    n_mark = s[ni][nj]
                    
    mark = n_mark

print("".join(ans))
0