結果
問題 | No.517 壊れたアクセサリー |
ユーザー | Mr.Fuku |
提出日時 | 2018-07-18 22:48:44 |
言語 | Python3 (3.11.6 + numpy 1.26.0 + scipy 1.11.3) |
結果 |
AC
|
実行時間 | 16 ms / 2,000 ms |
コード長 | 691 bytes |
コンパイル時間 | 171 ms |
コンパイル使用メモリ | 10,736 KB |
実行使用メモリ | 7,904 KB |
最終ジャッジ日時 | 2023-08-22 13:10:06 |
合計ジャッジ時間 | 1,731 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 15 ms
7,764 KB |
testcase_01 | AC | 16 ms
7,848 KB |
testcase_02 | AC | 16 ms
7,736 KB |
testcase_03 | AC | 15 ms
7,904 KB |
testcase_04 | AC | 16 ms
7,780 KB |
testcase_05 | AC | 15 ms
7,896 KB |
testcase_06 | AC | 15 ms
7,904 KB |
testcase_07 | AC | 15 ms
7,876 KB |
testcase_08 | AC | 15 ms
7,872 KB |
testcase_09 | AC | 15 ms
7,728 KB |
testcase_10 | AC | 15 ms
7,888 KB |
testcase_11 | AC | 15 ms
7,792 KB |
testcase_12 | AC | 14 ms
7,848 KB |
testcase_13 | AC | 15 ms
7,740 KB |
testcase_14 | AC | 16 ms
7,868 KB |
testcase_15 | AC | 14 ms
7,788 KB |
testcase_16 | AC | 15 ms
7,784 KB |
testcase_17 | AC | 16 ms
7,812 KB |
testcase_18 | AC | 15 ms
7,764 KB |
ソースコード
word_list = [[],[]] initial = [] head_w = [] word_length = 0 for i in range(int(input())): word = input() word_list[0].append(word) initial.append(word[0]) word_length += len(word) for i in range(int(input())): word = input() word_list[1].append(word) if word[0] in initial: head_w.append(word[0]) if len(head_w)!=1: print(-1) else: ans = head_w[0] choise_flag = 0 while len(ans)!=word_length: tgt = ans[-1] for i,w in enumerate(word_list[choise_flag]): if tgt in w: ans += w[w.index(tgt)+1:] word_list[choise_flag].pop(i) choise_flag = (choise_flag+1)%2 print(ans)