結果
問題 | No.2064 Smallest Sequence on Grid |
ユーザー | vwxyz |
提出日時 | 2023-01-14 23:54:46 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 672 bytes |
コンパイル時間 | 551 ms |
コンパイル使用メモリ | 87,384 KB |
実行使用メモリ | 86,740 KB |
最終ジャッジ日時 | 2023-08-27 04:28:05 |
合計ジャッジ時間 | 5,989 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 70 ms
71,396 KB |
testcase_01 | AC | 68 ms
71,472 KB |
testcase_02 | AC | 69 ms
71,304 KB |
testcase_03 | AC | 70 ms
71,556 KB |
testcase_04 | AC | 69 ms
71,420 KB |
testcase_05 | AC | 70 ms
71,176 KB |
testcase_06 | AC | 71 ms
71,308 KB |
testcase_07 | AC | 68 ms
71,424 KB |
testcase_08 | AC | 70 ms
71,312 KB |
testcase_09 | AC | 70 ms
71,360 KB |
testcase_10 | AC | 72 ms
71,292 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 138 ms
86,416 KB |
testcase_27 | WA | - |
testcase_28 | AC | 134 ms
86,344 KB |
testcase_29 | AC | 127 ms
85,320 KB |
testcase_30 | WA | - |
ソースコード
import sys readline=sys.stdin.readline H,W=map(int,readline().split()) S=[readline().rstrip() for h in range(H)] ans_lst=[S[0][0]] queue=[(0,0)] for _ in range(H+W-2): s="{" for h,w in queue: if h+1<H: s=min(s,S[h+1][w]) if w+1<W: s=min(s,S[h][w+1]) ans_lst.append(s) prev=queue queue=[] for h,w in prev: if w+1<W and S[h][w+1]==s: if queue and (h,w+1)==queue[-1]: continue queue.append((h,w+1)) if h+1<H and S[h+1][w]==s: if queue and (h+1,w)==queue[-1]: continue queue.append((h+1,w)) print("".join(ans_lst))