結果
問題 | No.2428 Returning Shuffle |
ユーザー | 沙耶花 |
提出日時 | 2023-08-18 21:51:37 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 451 ms / 2,000 ms |
コード長 | 905 bytes |
コンパイル時間 | 4,053 ms |
コンパイル使用メモリ | 269,052 KB |
実行使用メモリ | 11,264 KB |
最終ジャッジ日時 | 2024-11-28 06:38:25 |
合計ジャッジ時間 | 8,195 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <stdio.h> #include <atcoder/all> #include <bits/stdc++.h> using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 4000000000000000001 int main(){ int n,m; cin>>n>>m; vector<int> p(n); rep(i,n)p[i] = i; rep(i,m){ int t; cin>>t; vector<int> s(t); rep(j,t){ cin>>s[j]; s[j]--; } rep(j,t-1){ swap(p[s[(t-j)%t]],p[s[(t-j+1)%t]]); } } dsu D(n); rep(i,n)D.merge(i,p[i]); map<int,int> mp; rep(i,n){ if(D.leader(i)==i){ int nn = D.size(i); for(int j=2;j*j<=nn;j++){ if(nn%j==0){ int c = 0; while(nn%j==0){ nn /= j; c++; } mp[j] = max(mp[j],c); } } if(nn!=1)mp[nn] = max(mp[nn],1); } } mint ans = 1; for(auto a:mp){ ans *= mint(a.first).pow(a.second); } cout<<ans.val()<<endl; return 0; }