結果
| 問題 |
No.2064 Smallest Sequence on Grid
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2022-09-09 07:27:38 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 2,388 ms / 3,000 ms |
| コード長 | 595 bytes |
| コンパイル時間 | 164 ms |
| コンパイル使用メモリ | 82,164 KB |
| 実行使用メモリ | 133,312 KB |
| 最終ジャッジ日時 | 2024-11-25 05:00:27 |
| 合計ジャッジ時間 | 18,916 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 29 |
ソースコード
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=[[] for i in range(26)]
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]
D[ord(k)-97].append((z,w))
for i in range(26):
if D[i]!=[]:
ANS.append(chr(i+97))
break
Q=[]
for to in D[i]:
Q.append(to)
Q=list(set(Q))
print("".join(ANS))
titia