結果
| 問題 | No.517 壊れたアクセサリー |
| コンテスト | |
| ユーザー |
mkawa2
|
| 提出日時 | 2020-01-03 15:29:39 |
| 言語 | Python3 (3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 300 ms / 2,000 ms |
| + 803µs | |
| コード長 | 1,273 bytes |
| 記録 | |
| コンパイル時間 | 55 ms |
| コンパイル使用メモリ | 14,848 KB |
| 実行使用メモリ | 34,948 KB |
| 最終ジャッジ日時 | 2026-09-28 07:26:29 |
| 合計ジャッジ時間 | 7,701 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 15 |
ソースコード
from itertools import *
from bisect import *
# from math import *
from collections import *
from heapq import *
from random import *
from decimal import *
import numpy as np
import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
dij = [(0, 1), (1, 0), (0, -1), (-1, 0)]
def main():
an=II()
aa=[input() for _ in range(an)]
n=sum(len(a) for a in aa)
bn=II()
bb=[input() for _ in range(bn)]
to=defaultdict(str)
for ss in [aa,bb]:
for s in ss:
for c0,c1 in zip(s,s[1:]):
to[c0]=c1
for a in aa:
ans=a[0]
cnt=1
while to[ans[-1]]!="":
ans+=to[ans[-1]]
cnt+=1
if cnt==n:
print(ans)
exit()
print(-1)
main()
mkawa2