結果
問題 | No.2428 Returning Shuffle |
ユーザー |
![]() |
提出日時 | 2023-08-18 23:03:26 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 900 bytes |
コンパイル時間 | 2,330 ms |
コンパイル使用メモリ | 217,180 KB |
実行使用メモリ | 198,692 KB |
最終ジャッジ日時 | 2024-05-06 05:34:29 |
合計ジャッジ時間 | 7,708 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | WA | - |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 1 ms
5,376 KB |
testcase_09 | WA | - |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
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 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
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 | WA | - |
testcase_25 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <atcoder/modint> using mint = atcoder::modint998244353; #include <atcoder/scc> int main() { int n, m; cin >> n >> m; vector<int> p(n); iota(p.begin(), p.end(), 0); for (int i = 0; i < m; i++) { int t; cin >> t; vector<int> s(t); for (int j = 0; j < t; j++) { cin >> s[j]; s[j]--; } int start = p[s[t - 1]]; for (int j = t - 2; j >= 0; j--) { p[s[j + 1]] = p[s[j]]; } p[s[0]] = start; } atcoder::scc_graph g(n); int ed = 0; for (int i = 0; i < n; i++) { if (i == p[i]) { continue; } ed++; g.add_edge(i, p[i]); } if (ed == 0) { cout << 1 << endl; return 0; } auto res = g.scc(); mint sum = 1; int gd = 0; for (auto x : res) { sum *= x.size(); gd = __gcd(gd, (int)x.size()); } sum /= gd; cout << sum.val() << endl; }