結果
| 問題 | 
                            No.2064 Smallest Sequence on Grid
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2025-04-19 13:52:23 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 899 bytes | 
| コンパイル時間 | 454 ms | 
| コンパイル使用メモリ | 82,228 KB | 
| 実行使用メモリ | 85,152 KB | 
| 最終ジャッジ日時 | 2025-04-19 13:52:28 | 
| 合計ジャッジ時間 | 5,097 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 5 WA * 24 | 
ソースコード
## 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_word = "wwww"
        max_list = []
        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]
                    if max_word == s:
                        max_list.append((next_ci, next_cj))
                    elif max_word > s:
                        max_word = s
                        max_list = [(next_ci, next_cj)]
        answer.append(max_word)
        current = list(set(max_list))
    
    print("".join(answer))
if __name__ == "__main__":
    main()