結果

問題 No.2428 Returning Shuffle
ユーザー lloyzlloyz
提出日時 2023-08-19 14:42:29
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,223 bytes
コンパイル時間 662 ms
コンパイル使用メモリ 87,248 KB
実行使用メモリ 270,096 KB
最終ジャッジ日時 2023-08-19 14:42:40
合計ジャッジ時間 7,816 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,575 ms
270,096 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
P = [i for i in range(n + 1)]
NP = P[:]
for _ in range(m):
    t, *S = map(int, input().split())
    for i in range(t):
        ci, ni = S[i], S[(i + 1) % t]
        NP[ni] = P[ci]
    P = NP[:]
mod = 998244353

N = set()
seen = set()
for i in range(1, n + 1):
    if i in seen:
        continue
    cnt = 1
    seen.add(i)
    Stack = [i]
    while Stack:
        cp = Stack.pop()
        np = P[cp]
        if np in seen:
            continue
        seen.add(np)
        cnt += 1
        Stack.append(np)
    N.add(cnt)
ans = 1
PrimeCnt = defaultdict(int)
for num in N:
    if num % 2 == 0:
        cnt = 0
        while num % 2 == 0:
            num //= 2
            cnt += 1
        PrimeCnt[2] = max(PrimeCnt[2], cnt)
    f = 3
    while f * f <= num:
        if num % f == 0:
            cnt = 0
            while num % f == 0:
                num //= f
                cnt += 1
            PrimeCnt[f] = max(PrimeCnt[f], cnt)
        f += 2
    if num != 1:
        PrimeCnt[num] = max(PrimeCnt[num], 1)
ans = 1
for prime, cnt in PrimeCnt.items():
    ans *= pow(prime, cnt, mod)
    ans %= mod
print(ans)
0