結果
| 問題 | No.2064 Smallest Sequence on Grid |
| コンテスト | |
| ユーザー |
Kazun
|
| 提出日時 | 2022-09-02 22:01:55 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 598 bytes |
| 記録 | |
| コンパイル時間 | 450 ms |
| コンパイル使用メモリ | 81,980 KB |
| 実行使用メモリ | 493,840 KB |
| 最終ジャッジ日時 | 2024-11-16 03:29:31 |
| 合計ジャッジ時間 | 34,358 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 24 TLE * 5 |
ソースコード
def solve():
H,W=map(int,input().split())
S=[]
for _ in range(H):
S.append(list(input()))
T=[S[0][0]]
Y={(0,0)}
for _ in range(H+W-2):
X=Y
Y=set()
c=chr(ord("z")+1)
for i,j in X:
if i+1<H and S[i+1][j]<c:
c=S[i+1][j]
if j+1<W and S[i][j+1]<c:
c=S[i][j+1]
for i,j in X:
if i+1<H and S[i+1][j]==c:
Y.add((i+1,j))
if j+1<W and S[i][j+1]==c:
Y.add((i,j+1))
T.append(c)
return "".join(T)
print(solve())
Kazun