結果
問題 |
No.2064 Smallest Sequence on Grid
|
ユーザー |
|
提出日時 | 2022-09-02 22:11:29 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 580 bytes |
コンパイル時間 | 352 ms |
コンパイル使用メモリ | 81,864 KB |
実行使用メモリ | 849,304 KB |
最終ジャッジ日時 | 2024-11-16 03:49:38 |
合計ジャッジ時間 | 60,403 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 10 TLE * 5 MLE * 14 |
ソースコード
h,w = map(int,input().split()) S = [input() for i in range(h)] ans = [] ans.append(S[0][0]) l = [[0,0]] for i in range(h+w-1): cands = [[] for j in range(26)] for x,y in l: nx,ny = x+1,y if 0 <= nx < h and 0 <= ny < w: cands[ord(S[nx][ny])-ord("a")].append([nx,ny]) nx,ny = x,y+1 if 0 <= nx < h and 0 <= ny < w: cands[ord(S[nx][ny])-ord("a")].append([nx,ny]) for j in range(26): if cands[j] != []: l = cands[j] ans.append(chr(j+ord("a"))) break print(*ans,sep="")