結果
問題 | No.2064 Smallest Sequence on Grid |
ユーザー | 👑 tamato |
提出日時 | 2022-09-02 21:31:45 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,241 ms / 3,000 ms |
コード長 | 1,089 bytes |
コンパイル時間 | 429 ms |
コンパイル使用メモリ | 87,236 KB |
実行使用メモリ | 157,616 KB |
最終ジャッジ日時 | 2023-08-10 03:25:57 |
合計ジャッジ時間 | 18,308 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 67 ms
71,572 KB |
testcase_01 | AC | 67 ms
71,256 KB |
testcase_02 | AC | 70 ms
71,680 KB |
testcase_03 | AC | 67 ms
71,340 KB |
testcase_04 | AC | 67 ms
71,264 KB |
testcase_05 | AC | 67 ms
71,576 KB |
testcase_06 | AC | 67 ms
71,268 KB |
testcase_07 | AC | 68 ms
71,480 KB |
testcase_08 | AC | 75 ms
75,660 KB |
testcase_09 | AC | 71 ms
75,600 KB |
testcase_10 | AC | 75 ms
75,464 KB |
testcase_11 | AC | 77 ms
75,876 KB |
testcase_12 | AC | 81 ms
76,288 KB |
testcase_13 | AC | 78 ms
75,988 KB |
testcase_14 | AC | 82 ms
75,908 KB |
testcase_15 | AC | 82 ms
75,928 KB |
testcase_16 | AC | 77 ms
75,944 KB |
testcase_17 | AC | 921 ms
157,440 KB |
testcase_18 | AC | 787 ms
157,416 KB |
testcase_19 | AC | 778 ms
157,408 KB |
testcase_20 | AC | 1,152 ms
157,456 KB |
testcase_21 | AC | 1,159 ms
157,532 KB |
testcase_22 | AC | 1,065 ms
157,488 KB |
testcase_23 | AC | 1,078 ms
157,300 KB |
testcase_24 | AC | 1,076 ms
157,436 KB |
testcase_25 | AC | 1,078 ms
157,616 KB |
testcase_26 | AC | 1,203 ms
157,328 KB |
testcase_27 | AC | 1,241 ms
157,464 KB |
testcase_28 | AC | 785 ms
157,396 KB |
testcase_29 | AC | 1,029 ms
144,500 KB |
testcase_30 | AC | 721 ms
150,764 KB |
ソースコード
mod = 998244353 def main(): import sys input = sys.stdin.readline H, W = map(int, input().split()) G = [] for _ in range(H): G.append(input().rstrip('\n')) ans = [G[0][0]] ok = [[0] * W for _ in range(H)] ok[0][0] = 1 for hw in range(H + W - 2): mi = 27 for h in range(H): w = hw - h if 0 <= w < W: if not ok[h][w]: continue if h+1 < H: mi = min(mi, ord(G[h+1][w]) - 97) if w + 1 < W: mi = min(mi, ord(G[h][w+1]) - 97) for h in range(H): w = hw - h if 0 <= w < W: if not ok[h][w]: continue if h + 1 < H: if ord(G[h+1][w]) - 97 == mi: ok[h+1][w] = 1 if w + 1 < W: if ord(G[h][w+1]) - 97 == mi: ok[h][w+1] = 1 ans.append(chr(mi + 97)) print("".join(ans)) if __name__ == '__main__': main()