結果
問題 | No.2428 Returning Shuffle |
ユーザー |
|
提出日時 | 2023-08-18 22:24:33 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 660 bytes |
コンパイル時間 | 183 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 222,548 KB |
最終ジャッジ日時 | 2024-11-28 08:08:59 |
合計ジャッジ時間 | 19,406 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 WA * 3 TLE * 4 |
ソースコード
from math import gcd N, M = map(int, input().split()) P = [i+1 for i in range(N)] for _ in range(M): L, *T = list(map(int, input().split())) sigma = [] for t in T: t -= 1 sigma.append(P[t]) for i in range(L): if i < L-1: j = T[i+1]-1 else: j = T[0]-1 P[j] = sigma[i] loop = [] seen = [False]*N for i in range(N): if seen[i]: continue tmp = 1 next = P[i]-1 while next != i: seen[next] = True tmp += 1 next = P[next]-1 loop.append(tmp) ans = 1 MOD = 998244353 for c in loop: ans = ans*c//gcd(ans, c) ans %= MOD print(ans)