結果
| 問題 |
No.2064 Smallest Sequence on Grid
|
| コンテスト | |
| ユーザー |
H20
|
| 提出日時 | 2022-09-02 22:27:02 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 764 bytes |
| コンパイル時間 | 308 ms |
| コンパイル使用メモリ | 81,908 KB |
| 実行使用メモリ | 439,936 KB |
| 最終ジャッジ日時 | 2024-11-16 04:23:46 |
| 合計ジャッジ時間 | 24,971 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 23 WA * 2 RE * 4 |
ソースコード
H,W = map(int, input().split())
S = []
for _ in range(H):
S.append(list(input()+'~'))
S.append(list('~'*W))
pos = set()
pos.add(0)
ANS = [S[0][0]]
while len(ANS)<H+W-1:
alphabet = 'z'
nextPos = set()
for xy in list(pos):
x,y = xy%W,xy//W
if S[x+1][y]==alphabet:
nextPos.add(xy+1)
elif S[x+1][y]<alphabet:
alphabet = S[x+1][y]
nextPos = set()
nextPos.add(xy+1)
if not xy+W in nextPos:
if S[x][y+1]==alphabet:
nextPos.add(xy+W)
elif S[x][y+1]<alphabet:
alphabet = S[x][y+1]
nextPos = set()
nextPos.add(xy+W)
ANS.append(alphabet)
pos = nextPos
print(''.join(map(str, ANS)))
H20