結果

問題 No.1544 [Cherry 2nd Tune C] Synchroscope
ユーザー etale.K3etale.K3
提出日時 2021-10-17 11:21:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,638 ms / 2,000 ms
コード長 451 bytes
コンパイル時間 706 ms
コンパイル使用メモリ 11,796 KB
実行使用メモリ 11,872 KB
最終ジャッジ日時 2023-10-17 22:24:31
合計ジャッジ時間 4,870 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
10,188 KB
testcase_01 AC 30 ms
10,188 KB
testcase_02 AC 29 ms
10,188 KB
testcase_03 AC 31 ms
10,836 KB
testcase_04 AC 35 ms
11,416 KB
testcase_05 AC 37 ms
11,456 KB
testcase_06 AC 35 ms
11,500 KB
testcase_07 AC 34 ms
11,352 KB
testcase_08 AC 34 ms
10,940 KB
testcase_09 AC 35 ms
11,380 KB
testcase_10 AC 36 ms
11,516 KB
testcase_11 AC 33 ms
10,928 KB
testcase_12 AC 33 ms
11,016 KB
testcase_13 AC 31 ms
10,508 KB
testcase_14 AC 36 ms
11,268 KB
testcase_15 AC 39 ms
11,628 KB
testcase_16 AC 34 ms
11,244 KB
testcase_17 AC 32 ms
10,852 KB
testcase_18 AC 31 ms
10,424 KB
testcase_19 AC 31 ms
10,524 KB
testcase_20 AC 38 ms
11,536 KB
testcase_21 AC 33 ms
11,172 KB
testcase_22 AC 32 ms
10,496 KB
testcase_23 AC 41 ms
11,752 KB
testcase_24 AC 40 ms
11,752 KB
testcase_25 AC 40 ms
11,744 KB
testcase_26 AC 40 ms
11,752 KB
testcase_27 AC 39 ms
11,752 KB
testcase_28 AC 39 ms
11,748 KB
testcase_29 AC 40 ms
11,752 KB
testcase_30 AC 40 ms
11,752 KB
testcase_31 AC 40 ms
11,752 KB
testcase_32 AC 39 ms
11,748 KB
testcase_33 AC 1,638 ms
10,496 KB
testcase_34 AC 29 ms
10,188 KB
testcase_35 AC 30 ms
10,188 KB
testcase_36 AC 32 ms
10,240 KB
testcase_37 AC 33 ms
10,424 KB
testcase_38 AC 37 ms
11,832 KB
testcase_39 AC 37 ms
11,832 KB
testcase_40 AC 36 ms
11,872 KB
testcase_41 AC 37 ms
11,832 KB
testcase_42 AC 36 ms
11,836 KB
testcase_43 AC 36 ms
11,812 KB
testcase_44 AC 36 ms
11,816 KB
testcase_45 AC 37 ms
11,828 KB
testcase_46 AC 36 ms
11,820 KB
testcase_47 AC 36 ms
11,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

N, M = map(int, input().split())
A = map(int, input().split())
B = map(int, input().split())

D = dict()
g = math.gcd(N, M)
p = pow(N//g, -1, M//g)

for i, b in enumerate(B):
    if b in D:
        D[b] += [i]
    else:
        D[b] = [i]

l = N*M//g

for i, a in enumerate(A):
    if a in D:
        k = i%g
        for j in D[a]:
            if j%g == k:
                l = min(l, (j-i)*p%M//g*N + i)

print(-1 if l == N*M//g else 1+l)
0