結果

問題 No.1544 [Cherry 2nd Tune C] Synchroscope
ユーザー chinchillachinchilla
提出日時 2021-06-12 03:19:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,541 ms / 2,000 ms
コード長 467 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 10,932 KB
実行使用メモリ 10,048 KB
最終ジャッジ日時 2023-08-21 18:11:15
合計ジャッジ時間 4,983 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,932 KB
testcase_01 AC 16 ms
8,008 KB
testcase_02 AC 17 ms
7,864 KB
testcase_03 AC 20 ms
8,892 KB
testcase_04 AC 24 ms
9,412 KB
testcase_05 AC 23 ms
9,624 KB
testcase_06 AC 23 ms
9,744 KB
testcase_07 AC 23 ms
9,400 KB
testcase_08 AC 21 ms
8,952 KB
testcase_09 AC 22 ms
9,444 KB
testcase_10 AC 24 ms
9,560 KB
testcase_11 AC 21 ms
8,892 KB
testcase_12 AC 20 ms
9,016 KB
testcase_13 AC 18 ms
8,512 KB
testcase_14 AC 23 ms
9,416 KB
testcase_15 AC 26 ms
9,672 KB
testcase_16 AC 22 ms
9,304 KB
testcase_17 AC 20 ms
8,908 KB
testcase_18 AC 18 ms
8,428 KB
testcase_19 AC 19 ms
8,752 KB
testcase_20 AC 24 ms
9,768 KB
testcase_21 AC 20 ms
9,220 KB
testcase_22 AC 18 ms
8,612 KB
testcase_23 AC 27 ms
10,016 KB
testcase_24 AC 26 ms
9,812 KB
testcase_25 AC 27 ms
9,812 KB
testcase_26 AC 26 ms
9,836 KB
testcase_27 AC 26 ms
9,824 KB
testcase_28 AC 27 ms
9,848 KB
testcase_29 AC 26 ms
10,012 KB
testcase_30 AC 27 ms
9,960 KB
testcase_31 AC 26 ms
9,804 KB
testcase_32 AC 27 ms
9,792 KB
testcase_33 AC 1,541 ms
8,512 KB
testcase_34 AC 17 ms
7,944 KB
testcase_35 AC 17 ms
8,116 KB
testcase_36 AC 18 ms
8,464 KB
testcase_37 AC 20 ms
8,432 KB
testcase_38 AC 24 ms
9,964 KB
testcase_39 AC 24 ms
9,872 KB
testcase_40 AC 24 ms
9,928 KB
testcase_41 AC 23 ms
9,980 KB
testcase_42 AC 23 ms
9,988 KB
testcase_43 AC 24 ms
9,828 KB
testcase_44 AC 24 ms
9,928 KB
testcase_45 AC 24 ms
10,008 KB
testcase_46 AC 24 ms
10,008 KB
testcase_47 AC 24 ms
10,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
n, m = map(int, input().split())
A = map(int, input().split())
B = map(int, input().split())
l = math.gcd(n, m)
v = pow(n//l, -1, m//l)
d = dict()
for i, b in enumerate(B):
    if b in d:
        d[b] += [i]
    else:
        d[b] = [i]
r = n*m//l
for i, a in enumerate(A):
    if a in d:
        k = i%l
        for j in d[a]:
            if j%l == k:
                c = (j-i)*v%m//l*n + i
                r = min(r, c)
print(-1 if r == n*m//l else 1+r)
0