結果

問題 No.1655 123 Swaps
ユーザー chocoruskchocorusk
提出日時 2021-06-13 02:30:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,421 bytes
コンパイル時間 10,749 ms
コンパイル使用メモリ 298,940 KB
実行使用メモリ 15,540 KB
最終ジャッジ日時 2024-04-22 03:20:32
合計ジャッジ時間 13,736 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
8,576 KB
testcase_01 AC 5 ms
8,448 KB
testcase_02 WA -
testcase_03 AC 5 ms
8,448 KB
testcase_04 AC 6 ms
8,448 KB
testcase_05 AC 6 ms
8,448 KB
testcase_06 AC 6 ms
8,448 KB
testcase_07 AC 6 ms
8,448 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 6 ms
8,576 KB
testcase_14 AC 5 ms
8,448 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 6 ms
8,576 KB
testcase_33 AC 6 ms
8,448 KB
testcase_34 AC 5 ms
8,448 KB
testcase_35 AC 7 ms
8,576 KB
testcase_36 AC 14 ms
9,728 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 5 ms
8,576 KB
testcase_42 AC 5 ms
8,448 KB
testcase_43 AC 5 ms
8,704 KB
testcase_44 AC 5 ms
8,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "testlib.h"
#include <iostream>
#include <vector>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using mint=modint998244353;
mint f[600060], invf[600060];
void fac(int n){
    f[0]=1;
    for(int i=1; i<=n; i++) f[i]=f[i-1]*i;
    invf[n]=f[n].inv();
    for(int i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1);
}
mint comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]*invf[x-y];
}
const int MAX=200000;
int main(int argc, char* argv[]){
    registerValidation(argc, argv);
    int a=inf.readInt(0, MAX);
    inf.readSpace();
    int b=inf.readInt(0, MAX);
    inf.readSpace();
    int c=inf.readInt(0, MAX);
    ensure(a+b+c!=0);
    inf.readEoln();
    inf.readEof();
    
	int n=a+b+c;
    if(n%2!=0){
        cout<<0<<endl;
        return 0;
    }
    fac(n);
    mint ans=0;
    for(int p=0; p<3; p++){
        for(int q=0; q<3; q++){
            if((p+b-q+3)%3!=(a-p+q+3)%3) continue;
            vector<mint> vp(a+1), vq(b+1);
            for(int i=p; i<=a; i+=3){
                vp[i]=f[n/2]*invf[i]*invf[a-i];
            }
            for(int i=q; i<=b; i+=3){
                vq[i]=f[n/2]*invf[i]*invf[b-i];
            }
            auto v=convolution(vp, vq);
            for(int i=max(0, a+b-n/2); i<=n/2 && i<v.size(); i++){
                ans+=v[i]*invf[n/2-i]*invf[n/2-a-b+i];
            }
        }
    }
    cout<<ans.val()<<endl;
    return 0;
}
0