結果
問題 |
No.2064 Smallest Sequence on Grid
|
ユーザー |
![]() |
提出日時 | 2022-09-05 22:03:38 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 488 bytes |
コンパイル時間 | 162 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 38,144 KB |
最終ジャッジ日時 | 2024-11-20 22:59:54 |
合計ジャッジ時間 | 40,848 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 TLE * 9 |
ソースコード
H,W=map(int,input().split()) L=list() for i in range(H): s=input() L.append(s) ans=list() ans.append(L[0][0]) A=[0,0] def f(x,y): if 0<=x<H and 0<=y<W: return True return False stack=[[0,0]] for i in range(H+W-2): s="z" S=set() while stack: a,b=stack.pop() for da,db in [[1,0],[0,1]]: if f(a+da,b+db): s=min(s,L[a+da][b+db]) S.add((a+da,b+db)) for a,b in S: if L[a][b]==s: stack.append((a,b)) ans.append(s) print("".join(ans))