結果
| 問題 |
No.2064 Smallest Sequence on Grid
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-09-02 22:50:27 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,702 ms / 3,000 ms |
| コード長 | 615 bytes |
| コンパイル時間 | 528 ms |
| コンパイル使用メモリ | 82,296 KB |
| 実行使用メモリ | 168,268 KB |
| 最終ジャッジ日時 | 2024-11-16 05:20:24 |
| 合計ジャッジ時間 | 17,036 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 29 |
ソースコード
h, w = map(int, input().split())
S = [list(map(ord, list(input()))) for _ in range(h)]
Directions = [(1, 0), (0, 1)]
ans = chr(S[0][0])
C = set([0])
for _ in range(h + w - 2):
minT = 10**18
NC = set()
for c in C:
ci, cj = divmod(c, w)
for di, dj in Directions:
ni = ci + di
nj = cj + dj
if ni < h and nj < w:
if S[ni][nj] == minT:
NC.add(ni * w + nj)
elif S[ni][nj] < minT:
minT = S[ni][nj]
NC = set([ni * w + nj])
ans += chr(minT)
C = NC
print(ans)