結果

問題 No.1655 123 Swaps
ユーザー chocoruskchocorusk
提出日時 2021-06-13 01:53:40
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,155 bytes
コンパイル時間 3,008 ms
コンパイル使用メモリ 162,328 KB
実行使用メモリ 15,260 KB
最終ジャッジ日時 2024-04-22 03:19:57
合計ジャッジ時間 6,215 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
8,192 KB
testcase_01 AC 3 ms
8,392 KB
testcase_02 WA -
testcase_03 AC 3 ms
8,320 KB
testcase_04 AC 4 ms
8,132 KB
testcase_05 AC 4 ms
8,192 KB
testcase_06 AC 4 ms
8,260 KB
testcase_07 AC 3 ms
8,448 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 4 ms
8,260 KB
testcase_14 AC 3 ms
8,192 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 3 ms
8,192 KB
testcase_33 AC 3 ms
8,448 KB
testcase_34 AC 4 ms
8,132 KB
testcase_35 AC 6 ms
8,264 KB
testcase_36 AC 12 ms
9,472 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 4 ms
8,132 KB
testcase_42 AC 4 ms
8,320 KB
testcase_43 AC 4 ms
8,388 KB
testcase_44 AC 3 ms
8,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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];
}
int main()
{
    int a, b, c;
    cin>>a>>b>>c;
	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