結果
問題 |
No.205 マージして辞書順最小
|
ユーザー |
|
提出日時 | 2015-05-08 23:17:32 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 999 bytes |
コンパイル時間 | 77 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 341,272 KB |
最終ジャッジ日時 | 2024-07-05 20:21:03 |
合計ジャッジ時間 | 6,620 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 4 |
other | AC * 2 TLE * 1 -- * 12 |
ソースコード
def read_data(): N = int(input()) S= [] for i in range(N): S.append(input().rstrip()) return N, S def solve(N, S): SENTINEL = chr(ord('z') + 1) S = [s + SENTINEL for s in S] cursor = [0] * N frontiers = [cursor] T = [] while True: next_c = SENTINEL next_frontiers = [] for cursor in frontiers: for i, s in enumerate(S): c = s[cursor[i]] if c < next_c: next_c = c cursor[i] += 1 next_frontiers = [cursor[:]] cursor[i] -= 1 elif c == next_c: cursor[i] += 1 next_frontiers.append(cursor[:]) cursor[i] -= 1 if next_c == SENTINEL: return T T.append(next_c) frontiers = next_frontiers if __name__ == '__main__': N, S = read_data() minT = solve(N, S) print(''.join(minT))