結果

問題 No.1482 Swap Many Permutations
ユーザー tatyamtatyam
提出日時 2021-03-06 15:48:54
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 814 bytes
コンパイル時間 2,060 ms
コンパイル使用メモリ 197,300 KB
最終ジャッジ日時 2025-01-19 12:24:46
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 13 WA * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#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(2);
    for(auto& [B, C] : A) cin >> B >> C;
    puts("1");
    Modint ans = Modint(2).inv(), ans2 = Modint(2).inv(), x = Modint(M) * (M - 1), y = x / 2;
    if(A[0] == A[1]) puts("0");
    else cout << x.val() << '\n';
    ans *= x--;
    ans *= x--;
    ans2 *= 2;
    ans2 *= y--;
    for(int i = 3; i <= N; i++){
        ans *= x--;
        ans2 *= Modint::raw(i);
        if(i % 2 == 0){
            ans2 *= y--;
            ans2 /= Modint::raw(i / 2);
            if(i & 2) cout << (ans - ans2).val() << '\n';
            else cout << (ans + ans2).val() << '\n';
        }
        else cout << ans.val() << '\n';
    }
}
0