結果

問題 No.2428 Returning Shuffle
ユーザー 0214sh70214sh7
提出日時 2023-08-13 13:47:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,209 bytes
コンパイル時間 2,177 ms
コンパイル使用メモリ 218,796 KB
実行使用メモリ 26,952 KB
最終ジャッジ日時 2024-05-03 00:16:09
合計ジャッジ時間 6,300 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 293 ms
11,720 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 WA -
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 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 WA -
testcase_20 AC 318 ms
11,612 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 316 ms
26,952 KB
testcase_25 AC 316 ms
26,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll  = long long;
template<class T>
using vec = vector<T>;
template<class T, size_t S>
using arr = array<T, S>;
int main(){
	vec<ll> A, S;
	ll N, M, T;
	set<ll> L;
	cin >> N >> M;
	for (ll n = 0; n <= N; n++) A.emplace_back(n);
	for (ll m = 0; m < M; m++) {
		cin >> T;
		S.resize(T);
		for (ll t = 0; t < T; t++) cin >> S[t];
		S.emplace_back(0);
		for (ll t = T - 1; t >= 0; t--) A[S[t + 1]] = A[S[t]];
		A[S[0]] = A[0];
	}
	for (ll n = 1; n <= N; n++) if (A[n] != n) {
		ll now = n, d = 1, next;
		while (A[now] != n) {
			d++;
			next = A[now];
			A[now] = now;
			now = next;
		}
		A[now] = now;
		L.emplace(d);
	}
	vec<bool> P(1001, true);
	P[0] = P[1] = false;
	for (ll n = 2; n <= 1000; n++) if (P[n]) for (ll t = 2 * n; t <= 1000; t += n) P[t] = false;
	map<ll, ll> ans_fac;
	for (auto e : L) {
		ll rt = sqrt(e);
		map<ll, ll> fac;
		for (ll p = 2; p < rt; p++) if (P[p]) while (e % p == 0) fac[p]++, e /= p;
		fac[e]++;
		for (auto& i : fac) if (ans_fac[i.first] < i.second) ans_fac[i.first] = i.second;
	}
	ll ans = 1;
	for (auto e : ans_fac) for (ll i = 0; i < e.second; i++) ans = (ans * e.first) % 998244353;
	cout << ans << endl;
	return 0;
}
0