結果

問題 No.205 マージして辞書順最小
ユーザー rpy3cpp
提出日時 2015-05-08 23:03:24
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 648 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-07-05 19:34:50
合計ジャッジ時間 1,439 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 2
other AC * 8 WA * 7
権限があれば一括ダウンロードができます

ソースコード

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