結果

問題 No.1544 [Cherry 2nd Tune C] Synchroscope
ユーザー KudeKude
提出日時 2021-06-11 21:37:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 420 bytes
コンパイル時間 87 ms
コンパイル使用メモリ 10,724 KB
実行使用メモリ 15,256 KB
最終ジャッジ日時 2023-08-21 11:47:39
合計ジャッジ時間 12,772 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
12,468 KB
testcase_01 AC 16 ms
8,016 KB
testcase_02 AC 17 ms
7,956 KB
testcase_03 AC 967 ms
8,836 KB
testcase_04 TLE -
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 AC 1,983 ms
8,744 KB
testcase_09 AC 226 ms
8,940 KB
testcase_10 TLE -
testcase_11 AC 1,169 ms
8,780 KB
testcase_12 AC 1,146 ms
8,772 KB
testcase_13 AC 212 ms
8,684 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
ans = 10 ** 18
n, m = map(int, input().split())
g = gcd(n, m)
n2 = n // g
m2 = m // g
n2_inv = pow(n2, -1, m2)
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(n):
    for j in range(m):
        if (j - i) % g == 0 and a[i] == b[j]:
            k = n2_inv * (j - i) // g % m2
            ans = min(ans, i + k * n)
if ans == 10 ** 18:
    ans = -2
print(ans + 1)
0