結果
| 問題 |
No.1482 Swap Many Permutations
|
| コンテスト | |
| ユーザー |
👑 tatyam
|
| 提出日時 | 2021-03-06 16:09:22 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 78 ms / 2,000 ms |
| コード長 | 1,010 bytes |
| コンパイル時間 | 1,819 ms |
| コンパイル使用メモリ | 199,072 KB |
| 最終ジャッジ日時 | 2025-01-19 12:25:10 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 45 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using Modint = atcoder::modint998244353;
using Modint2 = atcoder::modint;
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;
Modint2::set_mod(M);
Modint2 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) ^ (i >> 1 & 1)) cout << (ans + ans2).val() << '\n';
else cout << (ans - ans2).val() << '\n';
}
else cout << ans.val() << '\n';
}
}
tatyam