結果
問題 | No.517 壊れたアクセサリー |
ユーザー |
![]() |
提出日時 | 2019-08-16 12:12:07 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 37 ms / 2,000 ms |
コード長 | 723 bytes |
コンパイル時間 | 212 ms |
コンパイル使用メモリ | 82,520 KB |
実行使用メモリ | 53,816 KB |
最終ジャッジ日時 | 2024-09-22 03:19:51 |
合計ジャッジ時間 | 1,846 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 15 |
ソースコード
N = int(input())A = [input() for _ in range(N)]M = int(input())B = [input() for _ in range(M)]for i in range(N):for j in range(M):if A[i][0] == B[j][0]:str0, str1 = A.pop(i), B.pop(j)breakelse:continuebreakwhile True:if str0 == str1:if len(A) == 0 and len(B) == 0:print(str0)else:print(-1)breakif len(str0) > len(str1):for i in range(len(B)):if B[i][0] == str0[len(str1)]:str1 += B.pop(i)breakelse:for i in range(len(A)):if A[i][0] == str1[len(str0)]:str0 += A.pop(i)break