結果
| 問題 |
No.2064 Smallest Sequence on Grid
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-19 13:50:08 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 970 bytes |
| コンパイル時間 | 612 ms |
| コンパイル使用メモリ | 82,188 KB |
| 実行使用メモリ | 231,160 KB |
| 最終ジャッジ日時 | 2025-04-19 13:50:39 |
| 合計ジャッジ時間 | 30,795 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 26 TLE * 3 |
ソースコード
## https://yukicoder.me/problems/no/2064
def main():
H, W= map(int ,input().split())
S = []
for _ in range(H):
S.append(input())
current = [(0, 0)]
answer = [S[0][0]]
for _ in range(H + W - 2):
max_words = {}
for ci, cj in current:
for di, dj in ((1, 0), (0, 1)):
next_ci = ci + di
next_cj = cj + dj
if 0 <= next_ci < H and 0 <= next_cj < W:
s = S[next_ci][next_cj]
max_words[(next_ci, next_cj)] = s
max_words_array = [(pos, w) for pos, w in max_words.items()]
max_words_array.sort(key=lambda x : x[1])
s0 = max_words_array[0][1]
answer.append(s0)
next_current = []
for pos, s in max_words_array:
if s == s0:
next_current.append(pos)
current = next_current
print("".join(answer))
if __name__ == "__main__":
main()