結果
| 問題 | 
                            No.2064 Smallest Sequence on Grid
                             | 
                    
| コンテスト | |
| ユーザー | 
                             SidewaysOwl
                         | 
                    
| 提出日時 | 2022-09-03 18:30:46 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 708 bytes | 
| コンパイル時間 | 428 ms | 
| コンパイル使用メモリ | 82,852 KB | 
| 実行使用メモリ | 849,148 KB | 
| 最終ジャッジ日時 | 2024-11-17 09:24:49 | 
| 合計ジャッジ時間 | 42,735 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 4 WA * 16 TLE * 6 MLE * 3 | 
ソースコード
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))
            
            
            
        
            
SidewaysOwl