結果

問題 No.2428 Returning Shuffle
ユーザー Akijin_007Akijin_007
提出日時 2023-08-18 22:22:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 797 ms / 2,000 ms
コード長 1,379 bytes
コンパイル時間 396 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 268,608 KB
最終ジャッジ日時 2024-05-06 04:36:47
合計ジャッジ時間 6,836 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 256 ms
117,056 KB
testcase_01 AC 797 ms
192,392 KB
testcase_02 AC 769 ms
192,136 KB
testcase_03 AC 71 ms
72,820 KB
testcase_04 AC 81 ms
72,448 KB
testcase_05 AC 81 ms
72,704 KB
testcase_06 AC 81 ms
72,704 KB
testcase_07 AC 81 ms
72,704 KB
testcase_08 AC 81 ms
73,344 KB
testcase_09 AC 82 ms
72,704 KB
testcase_10 AC 81 ms
72,704 KB
testcase_11 AC 82 ms
72,832 KB
testcase_12 AC 83 ms
72,832 KB
testcase_13 AC 82 ms
72,832 KB
testcase_14 AC 80 ms
72,832 KB
testcase_15 AC 81 ms
72,704 KB
testcase_16 AC 89 ms
72,832 KB
testcase_17 AC 81 ms
72,832 KB
testcase_18 AC 82 ms
72,832 KB
testcase_19 AC 417 ms
141,952 KB
testcase_20 AC 380 ms
141,876 KB
testcase_21 AC 70 ms
72,704 KB
testcase_22 AC 81 ms
72,576 KB
testcase_23 AC 81 ms
72,832 KB
testcase_24 AC 388 ms
268,608 KB
testcase_25 AC 385 ms
268,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#int(input())
#map(int, input().split())
#list(map(int, input().split()))

N, M = map(int, input().split())
T = [0] * M
S = [0] * M
for i in range(M):
    a = list(map(int, input().split()))
    T[i] = a[0]
    for j in range(a[0]):
        a[j+1] -= 1
    S[i] = a[1:]
mod = 998244353

# print(S[i])
l = list(range(N))
nl = list(range(N))
for i in range(M):
    t = T[i]
    u = l[S[i][t-2]]
    for j in range(t-2, -1, -1):
        l[S[i][(j)%t]] = l[S[i][(j-1)%t]]
    # l = list(nl)
    l[S[i][t-1]] = u

v = [-1] * N
u = []
# print(l)
for i in range(N):
    if v[i] == -1:
        q = l[i]
        c = 1
        v[i] = 1
        while q != i:
            v[q] = 1
            c += 1
            q = l[q]
        u.append(c)
    # print(i, v, u)

# print(l)
# print(u)

B = 10 ** 6 + 10
p = [-1] * B
for i in range(2, B):
    if p[i] != -1:
        continue
    for j in range(B):
        if i * j >= B:
            break
        p[i*j] = i


def prime_factorize(n):
    a = []
    while n != 1:
        u = p[n]
        a.append(u)
        n //= u
    return a

from collections import Counter

ps = dict()
for x in u:
    c = Counter(prime_factorize(x))
    for k, v in c.items():
        if k not in ps:
            ps[k] = v
        else:
            ps[k] = max(ps[k], v)
# print(ps)
ans = 1
for k, v in ps.items():
    ans = (ans * pow(k, v, mod)) % mod

print(ans)



0