結果
問題 | No.2064 Smallest Sequence on Grid |
ユーザー | FromBooska |
提出日時 | 2023-06-11 20:43:21 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,480 bytes |
コンパイル時間 | 1,300 ms |
コンパイル使用メモリ | 87,060 KB |
実行使用メモリ | 161,756 KB |
最終ジャッジ日時 | 2023-08-31 02:05:01 |
合計ジャッジ時間 | 10,146 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 61 ms
71,364 KB |
testcase_01 | AC | 61 ms
71,180 KB |
testcase_02 | AC | 59 ms
71,364 KB |
testcase_03 | AC | 60 ms
71,048 KB |
testcase_04 | AC | 61 ms
71,056 KB |
testcase_05 | AC | 61 ms
71,308 KB |
testcase_06 | AC | 61 ms
71,288 KB |
testcase_07 | AC | 59 ms
71,400 KB |
testcase_08 | RE | - |
testcase_09 | AC | 70 ms
76,192 KB |
testcase_10 | AC | 67 ms
75,620 KB |
testcase_11 | AC | 70 ms
76,136 KB |
testcase_12 | AC | 70 ms
76,056 KB |
testcase_13 | AC | 70 ms
76,456 KB |
testcase_14 | AC | 73 ms
76,320 KB |
testcase_15 | AC | 72 ms
76,152 KB |
testcase_16 | AC | 72 ms
76,392 KB |
testcase_17 | AC | 459 ms
157,364 KB |
testcase_18 | AC | 456 ms
157,056 KB |
testcase_19 | AC | 466 ms
157,032 KB |
testcase_20 | TLE | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
ソースコード
# 辞書順最小だから前から決めていく # 斜め線上にあるアルファベットで最小のものを全部残しその次のものからも最小を選ぶ H, W = map(int, input().split()) S = [] for i in range(H): temp = input() S.append(temp) #print(S) if H == 1: ans = S[0] print(ans) exit() elif W == 1: ans = '' for i in range(H): ans += S[i] print(ans) exit() usable = [[0]*W for h in range(H)] usable[0][0] = 1 ans = S[0][0] for d in range(1, H+W-1): if d < W: start = (0, d) length = min(H, d+1) else: start = (d - (W-1), W-1) length = H - (d - (W-1)) #print('d', d, 'start', start, 'length', length) smallest = 'zz' #辞書順最悪ダミー smallest_index = [] for i in range(length): if (start[0]+i-1 >= 0 and usable[start[0]+i-1][start[1]-i] == 1) or (start[1]-i-1 >=0 and usable[start[0]+i][start[1]-i-1] == 1): letter = S[start[0]+i][start[1]-i] if letter == smallest: smallest_index.append(start[0]+i) elif letter < smallest: smallest = letter smallest_index = [] smallest_index.append(start[0]+i) #print(smallest, smallest_index) ans += smallest for i in range(length): if start[0]+i in smallest_index: usable[start[0]+i][start[1]-i] = 1 #print(usable) #print() print(ans)