結果

問題 No.2428 Returning Shuffle
ユーザー kuronikuroni
提出日時 2023-08-18 21:42:56
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,405 bytes
コンパイル時間 3,623 ms
コンパイル使用メモリ 246,276 KB
実行使用メモリ 15,128 KB
最終ジャッジ日時 2023-08-18 21:43:19
合計ジャッジ時間 8,447 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using namespace atcoder;

using mint = modint998244353;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m; cin >> n >> m;
    vector<int> p(n);
    iota(p.begin(), p.end(), 0);
    while (m--) {
        int k; cin >> k;
        vector<int> pos(k);
        for (int i = 0; i < k; i++) {
            cin >> pos[i]; pos[i]--;
        }
        int st = p[pos[k - 1]];
        for (int i = k - 1; i >= 0; i--) {
            p[pos[i]] = p[pos[i - 1]];
        }
        p[pos[0]] = st;
    }
    vector<int> fct(n + 1), cnt(n + 1);
    for (int i = 2; i <= n; i++) {
        if (fct[i] == 0) {
            fct[i] = i;
            for (int j = i; j * i <= n; j++) {
                fct[i * j] = i;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        if (p[i] != -1) {
            int cur = -1;
            for (int u = i; u != -1; cur++) {
                int v = p[u]; p[u] = -1; u = v;
            }
            for (; cur != 1; ) {
                int d = fct[cur], cd = 0;
                while (cur % d == 0) {
                    cd++;
                    cur /= d;
                }
                cnt[d] = max(cnt[d], cd);
            }
        }
    }
    mint ans = 1;
    for (int i = 2; i <= n; i++) {
        ans *= mint(i).pow(cnt[i]);
    }
    cout << ans.val();
}
0