結果

問題 No.1482 Swap Many Permutations
ユーザー 👑 tatyamtatyam
提出日時 2021-03-06 16:09:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 1,010 bytes
コンパイル時間 2,512 ms
コンパイル使用メモリ 200,808 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 04:50:55
合計ジャッジ時間 7,395 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 35 ms
5,376 KB
testcase_13 AC 33 ms
5,376 KB
testcase_14 AC 77 ms
5,376 KB
testcase_15 AC 60 ms
5,376 KB
testcase_16 AC 15 ms
5,376 KB
testcase_17 AC 56 ms
5,376 KB
testcase_18 AC 18 ms
5,376 KB
testcase_19 AC 31 ms
5,376 KB
testcase_20 AC 61 ms
5,376 KB
testcase_21 AC 68 ms
5,376 KB
testcase_22 AC 80 ms
5,376 KB
testcase_23 AC 79 ms
5,376 KB
testcase_24 AC 78 ms
5,376 KB
testcase_25 AC 79 ms
5,376 KB
testcase_26 AC 78 ms
5,376 KB
testcase_27 AC 79 ms
5,376 KB
testcase_28 AC 80 ms
5,376 KB
testcase_29 AC 79 ms
5,376 KB
testcase_30 AC 78 ms
5,376 KB
testcase_31 AC 78 ms
5,376 KB
testcase_32 AC 80 ms
5,376 KB
testcase_33 AC 83 ms
5,376 KB
testcase_34 AC 80 ms
5,376 KB
testcase_35 AC 80 ms
5,376 KB
testcase_36 AC 81 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 2 ms
5,376 KB
testcase_39 AC 2 ms
5,376 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 27 ms
5,376 KB
testcase_43 AC 27 ms
5,376 KB
testcase_44 AC 26 ms
5,376 KB
testcase_45 AC 31 ms
5,376 KB
testcase_46 AC 34 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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';
    }
}
0