結果

問題 No.517 壊れたアクセサリー
コンテスト
ユーザー GrayCoder
提出日時 2017-05-28 23:00:55
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 687 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 754 ms
コンパイル使用メモリ 20,700 KB
実行使用メモリ 21,628 KB
最終ジャッジ日時 2026-04-09 21:12:21
合計ジャッジ時間 11,835 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 6 WA * 3 TLE * 1 -- * 5
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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)]

    ans = ''
    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