結果

問題 No.1655 123 Swaps
コンテスト
ユーザー 👑 potato167
提出日時 2026-01-06 16:45:45
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
結果
AC  
実行時間 153 ms / 2,000 ms
コード長 9,060 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,248 ms
コンパイル使用メモリ 263,524 KB
実行使用メモリ 14,608 KB
最終ジャッジ日時 2026-01-06 16:45:54
合計ジャッジ時間 7,429 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 42
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#line 1 "g.cpp"
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll ILL=2167167167167167167;
const int INF=2100000000;
#define rep(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define all(p) p.begin(),p.end()
template<class T> using _pq = priority_queue<T, vector<T>, greater<T>>;
template<class T> int LB(vector<T> &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> int UB(vector<T> &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> bool chmin(T &a,T b){if(b<a){a=b;return 1;}else return 0;}
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return 1;}else return 0;}
template<class T> void So(vector<T> &v) {sort(v.begin(),v.end());}
template<class T> void Sore(vector<T> &v) {sort(v.begin(),v.end(),[](T x,T y){return x>y;});}
bool yneos(bool a,bool upp=false){if(a){cout<<(upp?"YES\n":"Yes\n");}else{cout<<(upp?"NO\n":"No\n");}return a;}
template<class T> void vec_out(vector<T> &p,int ty=0){
    if(ty==2){cout<<'{';for(int i=0;i<(int)p.size();i++){if(i){cout<<",";}cout<<'"'<<p[i]<<'"';}cout<<"}\n";}
    else{if(ty==1){cout<<p.size()<<"\n";}for(int i=0;i<(int)(p.size());i++){if(i) cout<<" ";cout<<p[i];}cout<<"\n";}}
template<class T> T vec_min(vector<T> &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmin(ans,x);return ans;}
template<class T> T vec_max(vector<T> &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmax(ans,x);return ans;}
template<class T> T vec_sum(vector<T> &a){T ans=T(0);for(auto &x:a) ans+=x;return ans;}
int pop_count(long long a){int res=0;while(a){res+=(a&1),a>>=1;}return res;}
template<class T> T square(T a){return a * a;}

#include <atcoder/convolution>
using mint = atcoder::static_modint<924844033>;
#line 2 "/Users/Shared/po167_library/math/Binomial.hpp"

#line 5 "/Users/Shared/po167_library/math/Binomial.hpp"

namespace po167{
template<class T>
struct Binomial{
    std::vector<T> fact_vec, fact_inv_vec;
    void extend(int m = -1){
        int n = fact_vec.size();
        if (m == -1) m = n * 2;
        if (n >= m) return;
        fact_vec.resize(m);
        fact_inv_vec.resize(m);
        for (int i = n; i < m; i++){
            fact_vec[i] = fact_vec[i - 1] * T(i);
        }
        fact_inv_vec[m - 1] = T(1) / fact_vec[m - 1];
        for (int i = m - 1; i > n; i--){
            fact_inv_vec[i - 1] = fact_inv_vec[i] * T(i);
        }
    }
    Binomial(int MAX = 0){
        fact_vec.resize(1, T(1));
        fact_inv_vec.resize(1, T(1));
        extend(MAX + 1);
    }

    T fact(int i){
        if (i < 0) return 0;
        while (int(fact_vec.size()) <= i) extend();
        return fact_vec[i];
    }
    T invfact(int i){
        if (i < 0) return 0;
        while (int(fact_inv_vec.size()) <= i) extend();
        return fact_inv_vec[i];
    }
    T C(int a, int b){
        if (a < b || b < 0) return 0;
        return fact(a) * invfact(b) * invfact(a - b);
    }
    T invC(int a, int b){
        if (a < b || b < 0) return 0;
        return fact(b) * fact(a - b) *invfact(a);
    }
    T P(int a, int b){
        if (a < b || b < 0) return 0;
        return fact(a) * invfact(a - b);
    }
    T inv(int a){
        if (a < 0) return inv(-a) * T(-1);
        if (a == 0) return 1;
        return fact(a - 1) * invfact(a);
    }
    T Catalan(int n){
        if (n < 0) return 0;
        return fact(2 * n) * invfact(n + 1) * invfact(n);
    }
    T narayana(int n, int k){
        if (n <= 0 || n < k || k < 1) return 0;
        return C(n, k) *  C(n, k - 1) * inv(n);
    }
    T Catalan_pow(int n,int d){
        if (n < 0 || d < 0) return 0;
        if (d == 0){
            if (n == 0) return 1;
            return 0;
        }
        return T(d) * inv(d + n) * C(2 * n + d - 1, n);
    }
    // retrun [x^a] 1/(1-x)^b
    T ruiseki(int a,int b){
        if (a < 0 || b < 0) return 0;
        if (a == 0){
            return 1;
        }
        return C(a + b - 1, b - 1);
    }
    // (a, b) -> (c, d)
    // always x + e >= y
    T mirror(int a, int b, int c, int d, int e = 0){
        if (a + e < b || c + e < d) return 0;
        if (a > c || b > d) return 0;
        a += e;
        c += e;
        return C(c + d - a - b, c - a) - C(c + d - a - b, c - b + 1); 
    }
    // return sum_{i = 0, ... , a} sum_{j = 0, ... , b} C(i + j, i)
    // return C(a + b + 2, a + 1) - 1;
    T gird_sum(int a, int b){
        if (a < 0 || b < 0) return 0;
        return C(a + b + 2, a + 1) - 1;
    }
    // return sum_{i = a, ..., b - 1} sum_{j = c, ... , d - 1} C(i + j, i)
    // AGC 018 E
    T gird_sum_2(int a, int b, int c, int d){
        if (a >= b || c >= d) return 0;
        a--, b--, c--, d--;
        return gird_sum(a, c) - gird_sum(a, d) - gird_sum(b, c) + gird_sum(b, d);
    }

    // the number of diagonal dissections of a convex n-gon into k+1 regions.
    // OEIS A033282
    // AGC065D
    T diagonal(int n, int k){
        if (n <= 2 || n - 3 < k || k < 0) return 0;
        return C(n - 3, k) * C(n + k - 1, k) * inv(k + 1);
    }
};
}
#line 28 "g.cpp"

void solve();
// DEAR MYSTERIES / TOMOO
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
    // cin >> t;
    rep(i, 0, t) solve();
}

void solve(){
    po167::Binomial<mint> table;
    int A, B, C;
    cin >> A >> B >> C;
    if ((A + B + C) & 1){
        cout << "0\n";
        return;
    }
    /*auto f = [&](mint t) -> mint {
        mint res = 0;
        rep(a, 0, A + 1) rep(b, 0, B + 1) rep(c, 0, C + 1){
            if ((A - a) & 1) continue;
            if ((B - b) & 1) continue;
            if ((C - c) & 1) continue;
            mint tmp = 1;
            int n = (a + b + c) / 2;
            tmp *= t.pow(n);
            tmp *= table.invfact((A - a) / 2);
            tmp *= table.invfact((B - b) / 2);
            tmp *= table.invfact((C - c) / 2);
            tmp *= table.invfact(n - a);
            tmp *= table.invfact(n - b);
            tmp *= table.invfact(n - c);
            res += tmp;
            // cout << a << " " << b << " " << c << " " << tmp.val() << endl;
        }
        res *= table.fact((A + B + C) / 2);
        return res;
    };*/
    /*auto f = [&](mint t) -> mint {
        mint res = 0;
        int N = (A + B + C) / 2;
        rep(x, 0, A / 2 + 1) rep(y, 0, B / 2 + 1) rep(z, 0, C / 2 + 1){
            mint tmp = 1;
            tmp *= t.pow(N - x - y - z);
            tmp *= table.invfact(x);
            tmp *= table.invfact(y);
            tmp *= table.invfact(z);
            tmp *= table.invfact(N + x - y - z - A);
            tmp *= table.invfact(N - x + y - z - B);
            tmp *= table.invfact(N - x - y + z - C);
            res += tmp;
            // cout << a << " " << b << " " << c << " " << tmp.val() << endl;
        }
        res *= table.fact(N);
        return res;
    };
    mint ans = 0;
    ans += f(2) * table.inv(3);
    ans += f(-1) * table.inv(3) * 2;
    cout << ans.val() << "\n";*/
    int N = (A + B + C) / 2;
    mint ans = 0;
    rep(i, 0, 3){
        vector<mint> X(A + 1), Y(B + 1);
        rep(j, 0, A + 1){
            if ((N * 3 + A - j * 2) % 3 == i) X[j] = table.invfact(j) * table.invfact(A - j);
        }
        rep(j, 0, B + 1) {
            if ((N * 3 + B - j * 2) % 3 == i) Y[j] = table.invfact(j) * table.invfact(B - j);
        }
        auto tmp = atcoder::convolution(X, Y);
        rep(j, 0, tmp.size()){
            ans += table.invfact(N - j) * table.invfact(C - (N - j)) * tmp[j];
        }
    }
    /*rep(a, 0, A + 1) rep(b, 0, B + 1) rep(c, 0, C + 1){
        if (a + b + c != N) continue;
        if ((a + B - b) % 3 != (b + A - a) % 3) continue;
        // if ((B - 2 * b) % 3 != (A - 2 * a) % 3) continue;
        ans += table.invfact(a) * table.invfact(A - a) * table.invfact(b) * table.invfact(B - b) * table.invfact(c) * table.invfact(C - c);
    }*/
    ans *= table.fact(N);
    ans *= table.fact(N);
    cout << ans.val() << "\n";
}

/*
 * 同じのを 2 回、
 * 違うのを 2 回するのいずれかで、
 * 違うのを 2 回するときは、ローテートになる。
 * 全部違うような確率をまず求める。
 * a + b + c = 2n として、
 * C(n, a) * C(a, a + b - n)
 * = n! / (n - a)! * (n - b)! * (n - c)!
 * おお
 * 違うものが k 個のときに、戻る事象は、
 * k が偶数なら、(2^k + 2) / 3
 * k が奇数なら、(2^k - 2) / 3
 * (2^k + 2 * (-1)^k) / 3
 * 違うやつ一つにつき、寄与が t だとして問題を 2 回解いたらいい(t = 2, -1)
 * A = 2x + a
 * B = 2y + b
 * C = 2z + c としたとき、
 * t^{a + b + c} / (x! * y! * z! * ((a + b - c) / 2)! * ((b + c - a) / 2)! * ((c + a - b) / 2)!)
 *
 * とりあえず O(ABC) ではとけた
 *
 * tips : sqrt(2), sqrt(-1) はどちらも定義できる
 *
 * a + b - c = A + B - C - 2x - 2y + 2z
 * (a + b - c) / 2 = (A + B + C) / 2 - x - y + z - C
 * 全然ダメなので、もっと考える
 * 操作 1, 2, 3 の値をそれとしていい
 * 偶数回目の操作を +1
 * 奇数回目の操作を -1 としたとき、
 * 寄与の和が 3 の倍数になる?
 */
0