結果

問題 No.1544 [Cherry 2nd Tune C] Synchroscope
ユーザー Manuel1024
提出日時 2021-05-19 19:43:29
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 485 bytes
コンパイル時間 648 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 51,416 KB
最終ジャッジ日時 2024-12-14 21:36:17
合計ジャッジ時間 53,979 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 38 TLE * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cnt1 = [0 for i in range(10010)]
isexist = False
for v in a:
    cnt1[v] += 1
for v in b:
    if cnt1[v] > 0:
        isexist = True
        break

if not isexist:
    print(-1)
    exit()

ans = -1
loopnum = max(n, m) if max(n, m) % min(n, m) == 0 else np.lcm(n, m)
for i in range(loopnum):
    if a[i%n] == b[i%m]:
        ans = i+1
        break
print(ans)
0