結果

問題 No.205 マージして辞書順最小
ユーザー SuzumePythonSuzumePython
提出日時 2017-02-09 12:57:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,128 bytes
コンパイル時間 110 ms
コンパイル使用メモリ 10,860 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2023-08-26 17:48:36
合計ジャッジ時間 1,934 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,868 KB
testcase_01 AC 16 ms
7,868 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 16 ms
7,844 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 33 ms
7,808 KB
testcase_11 AC 39 ms
7,828 KB
testcase_12 WA -
testcase_13 AC 33 ms
7,864 KB
testcase_14 AC 17 ms
7,788 KB
testcase_15 AC 16 ms
7,784 KB
testcase_16 AC 17 ms
7,932 KB
testcase_17 AC 16 ms
7,872 KB
testcase_18 AC 17 ms
7,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

num = int(input())

words= []

for i in range(num):
    words.append(input())

dict_list = []

for i in range(len(words)):
    if words[i].endswith('z'): #zで終わる時だけの処理
        words[i] = words[i] + 'あ' #日本語ならなんでも

while words != []: #wordsが空になるまで
    if '' in words: #wordsに空の文字列があったら
        words.remove('') #取り除く
    num_list = range(len(words)) #辞書用に、インデックスキーのリストを生成
    word_dict = dict(zip(num_list, words)) #インデックスと文字リストを辞書でパッキング
    if word_dict == {}: #辞書が空になったら
        break #終了させる
    key_list = sorted(word_dict.items(), key=lambda x: x[1]) #辞書を文字をキーにソートしてリスト化
###    print(key_list) ###後で消す
    dict_list.append(words[key_list[0][0]][0]) #最初に来た文字の頭文字をリストに追加
    words[key_list[0][0]] = words[key_list[0][0]][1:] #最初に来た文字の頭文字を削除
###    print(words) ###後で消す

    
print(''.join(dict_list).replace('あ',''))
0