結果

問題 No.2428 Returning Shuffle
ユーザー 沙耶花沙耶花
提出日時 2023-08-18 21:51:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 436 ms / 2,000 ms
コード長 905 bytes
コンパイル時間 4,165 ms
コンパイル使用メモリ 268,928 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-05-06 03:50:53
合計ジャッジ時間 8,268 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 297 ms
11,264 KB
testcase_01 AC 436 ms
11,008 KB
testcase_02 AC 433 ms
11,136 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 316 ms
11,008 KB
testcase_20 AC 326 ms
11,136 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 314 ms
11,152 KB
testcase_25 AC 320 ms
11,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0