結果

問題 No.2428 Returning Shuffle
ユーザー maeshunmaeshun
提出日時 2023-08-19 08:03:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 672 ms / 2,000 ms
コード長 1,461 bytes
コンパイル時間 4,705 ms
コンパイル使用メモリ 241,192 KB
実行使用メモリ 198,676 KB
最終ジャッジ日時 2024-05-06 15:18:35
合計ジャッジ時間 11,312 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 340 ms
39,200 KB
testcase_01 AC 596 ms
50,572 KB
testcase_02 AC 591 ms
51,596 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 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 2 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 1 ms
5,376 KB
testcase_19 AC 532 ms
93,796 KB
testcase_20 AC 538 ms
101,552 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 672 ms
198,676 KB
testcase_25 AC 663 ms
198,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define rep(i, n) for(int i=0;i<(n);++i)
#define rep1(i, n) for(int i=1;i<=(n);i++)
#define ll long long
using mint = modint998244353;
using P = pair<ll,ll>;
using lb = long double;
using T = tuple<ll, ll, ll>;
#ifdef LOCAL
#  include <debug_print.hpp>
#  define dbg(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#  define dbg(...) (static_cast<void>(0))
#endif

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i,n) a[i] = i;
    rep(i,m){
        int t;
        cin >> t;
        vector<int> b(t);
        rep(j,t){
            cin >> b[j];
            --b[j]; 
        } 
        reverse(b.begin(),b.end());
        rep(j,t-1){
            swap(a[b[j]], a[b[j+1]]);
        }
    }
    scc_graph g(n);
    rep(i,n){
        g.add_edge(i, a[i]);
    }
    dbg(a);
    auto res = g.scc();
    map<int, int> mp;
    for(auto vs : res){
        int v = vs.size();
        for(int r=2;r*r<=v;r++){
            if(v%r==0){
                int cnt = 0;
                while(v%r==0) {
                    v /=r;
                    cnt++;
                }
                mp[r] = max(mp[r], cnt);
            }
        }
        if(v!=1){
            mp[v] = max(mp[v], 1);
        }
    }
    mint ans = 1;
    for(auto p : mp){
        ans *= mint(p.first).pow(p.second);
    }
    cout << ans.val() << endl;
    return 0;
}
0