結果

問題 No.205 マージして辞書順最小
ユーザー rpy3cpprpy3cpp
提出日時 2015-05-08 23:03:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 648 bytes
コンパイル時間 1,508 ms
コンパイル使用メモリ 10,804 KB
実行使用メモリ 7,988 KB
最終ジャッジ日時 2023-09-19 07:34:33
合計ジャッジ時間 1,921 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,788 KB
testcase_01 AC 16 ms
7,844 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 16 ms
7,792 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 27 ms
7,884 KB
testcase_11 AC 26 ms
7,764 KB
testcase_12 AC 27 ms
7,720 KB
testcase_13 AC 27 ms
7,784 KB
testcase_14 AC 16 ms
7,784 KB
testcase_15 AC 16 ms
7,708 KB
testcase_16 AC 16 ms
7,836 KB
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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
    T = []
    while True:
        next_c = SENTINEL
        next_i = 0
        for i, s in enumerate(S):
            c = s[cursor[i]]
            if c < next_c:
                next_c = c
                next_i = i
        if next_c == SENTINEL:
            return T
        T.append(next_c)
        cursor[next_i] += 1

if __name__ == '__main__':
    N, S = read_data()
    minT = solve(N, S)
    print(''.join(minT))
0