結果

問題 No.517 壊れたアクセサリー
ユーザー GrayCoder
提出日時 2017-05-28 22:13:24
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 444 bytes
コンパイル時間 226 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 16,128 KB
最終ジャッジ日時 2024-09-21 15:31:42
合計ジャッジ時間 4,168 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 9 TLE * 1 -- * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

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

    cnt = 0
    for a in itertools.permutations(A):
        for b in itertools.permutations(B):
            a_ = ''.join(a)
            b_ = ''.join(b)
            if a_ == b_:
                ans = a_
                cnt += 1

    if cnt > 1:
        print(-1)
    else:
        print(ans)

main()
0