結果

問題 No.517 壊れたアクセサリー
ユーザー GrayCoderGrayCoder
提出日時 2017-05-28 22:59:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 674 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 11,908 KB
実行使用メモリ 10,196 KB
最終ジャッジ日時 2023-10-21 14:31:15
合計ジャッジ時間 1,569 ms
ジャッジサーバーID
(参考情報)
judge15 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 30 ms
10,128 KB
testcase_02 WA -
testcase_03 RE -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 30 ms
10,128 KB
testcase_07 AC 29 ms
10,128 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 35 ms
10,128 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 29 ms
10,128 KB
testcase_18 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools
import sys

def main():
    N = int(input())
    A = [input() for i in range(N)]
    M = int(input())
    B = [input() for i in range(M)]

    for a in A:
        if len(a) > 1:
            break
    else:
        ans = -1
    for b in B:
        if len(b) > 1:
            break
    else:
        ans = -1
    if tuple(sorted(A)) == tuple(sorted(B)):
        ans = -1
    if ans == -1:
        print(-1)
        sys.exit()

    for a in itertools.permutations(A):
        a_ = ''.join(a)
        for b in itertools.permutations(B):
            b_ = ''.join(b)
            if a_ == b_:
                ans = b_
                break

    print(ans)

main()
0