結果
| 問題 | 
                            No.2064 Smallest Sequence on Grid
                             | 
                    
| コンテスト | |
| ユーザー | 
                             titia
                         | 
                    
| 提出日時 | 2022-09-09 07:23:09 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 626 bytes | 
| コンパイル時間 | 465 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 38,528 KB | 
| 最終ジャッジ日時 | 2024-11-25 04:56:25 | 
| 合計ジャッジ時間 | 40,819 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 20 TLE * 9 | 
ソースコード
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=dict()
    
    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]
                if not(k in D):
                    D[k]=([(z,w)])
                else:
                    D[k].append((z,w))
    if list(D)==[]:
        break
    MIN=min(D)
    ANS.append(MIN)
    Q=[]
    for to in D[MIN]:
        Q.append(to)
    Q=list(set(Q))
        
print("".join(ANS))   
                
            
            
            
            
        
            
titia