結果
問題 |
No.1482 Swap Many Permutations
|
ユーザー |
👑 ![]() |
提出日時 | 2021-03-06 15:53:05 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 923 bytes |
コンパイル時間 | 2,003 ms |
コンパイル使用メモリ | 199,292 KB |
最終ジャッジ日時 | 2025-01-19 12:24:57 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 1 |
other | AC * 12 WA * 33 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/modint> using namespace std; using Modint = atcoder::modint998244353; int main(){ int N, M; cin >> N >> M; vector<pair<int, int>> A(N); for(auto& [B, C] : A) cin >> B >> C; cout << 1 << '\n'; Modint ans = Modint(2).inv(), ans2 = Modint(2).inv(), x = Modint(M) * (M - 1), y = x / 2, z = 1; if(A[0] == A[1]) cout << 0 << '\n'; else cout << x.val() << '\n'; ans *= x--; z *= A[0].second; ans *= x--; z *= A[1].second; ans2 *= 2; ans2 *= y--; for(int i = 3; i <= N; i++){ ans *= x--; z *= A[i - 1].second; ans2 *= Modint::raw(i); if(i % 2 == 0){ ans2 *= y--; ans2 /= Modint::raw(i / 2); if(z.pow(M / 2) == 1) cout << (ans + ans2).val() << '\n'; else cout << (ans - ans2).val() << '\n'; } else cout << ans.val() << '\n'; } }