結果

問題 No.1683 Robot Guidance
ユーザー Focus_SashFocus_Sash
提出日時 2021-09-17 23:06:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 4,693 bytes
コンパイル時間 5,675 ms
コンパイル使用メモリ 260,516 KB
実行使用メモリ 34,844 KB
最終ジャッジ日時 2023-09-12 09:10:01
合計ジャッジ時間 29,637 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 521 ms
34,664 KB
testcase_01 AC 522 ms
34,596 KB
testcase_02 AC 522 ms
34,576 KB
testcase_03 AC 527 ms
34,768 KB
testcase_04 AC 522 ms
34,588 KB
testcase_05 AC 525 ms
34,576 KB
testcase_06 AC 529 ms
34,580 KB
testcase_07 AC 526 ms
34,572 KB
testcase_08 AC 549 ms
34,648 KB
testcase_09 AC 526 ms
34,812 KB
testcase_10 AC 536 ms
34,588 KB
testcase_11 AC 533 ms
34,576 KB
testcase_12 AC 546 ms
34,692 KB
testcase_13 AC 525 ms
34,572 KB
testcase_14 AC 541 ms
34,572 KB
testcase_15 AC 527 ms
34,688 KB
testcase_16 AC 522 ms
34,588 KB
testcase_17 AC 521 ms
34,768 KB
testcase_18 AC 520 ms
34,840 KB
testcase_19 AC 522 ms
34,580 KB
testcase_20 AC 522 ms
34,620 KB
testcase_21 AC 521 ms
34,592 KB
testcase_22 AC 525 ms
34,656 KB
testcase_23 AC 525 ms
34,592 KB
testcase_24 AC 552 ms
34,576 KB
testcase_25 AC 525 ms
34,620 KB
testcase_26 AC 527 ms
34,712 KB
testcase_27 AC 529 ms
34,640 KB
testcase_28 AC 525 ms
34,592 KB
testcase_29 AC 525 ms
34,648 KB
testcase_30 AC 525 ms
34,656 KB
testcase_31 AC 525 ms
34,708 KB
testcase_32 AC 524 ms
34,844 KB
testcase_33 AC 531 ms
34,580 KB
testcase_34 AC 532 ms
34,588 KB
testcase_35 AC 531 ms
34,616 KB
testcase_36 AC 531 ms
34,664 KB
testcase_37 AC 524 ms
34,808 KB
testcase_38 WA -
testcase_39 AC 525 ms
34,632 KB
testcase_40 AC 522 ms
34,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using vl = vector<long long>;
using pl = pair<long long, long long>;
struct edge {long long to;long long cost;edge(long long t,long long c):to(t),cost(c){}};
using Graph = vector<vector<long long>>;
using WGraph = vector<vector<edge>>;
constexpr int dx[8]{1,0,-1,0,1,1,-1,-1};
constexpr int dy[8]{0,1,0,-1,1,-1,1,-1};
#define rep(i, n) for(long long (i) = 0; (i) < (n); (i)++)
#define reps(i, a, b) for(long long (i) = (a); (i) < (b); (i)++)
#define rrep(i, a, b) for(long long (i) = (a); (i) >= (b); (i)--)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define V vector
constexpr long long MOD1 = 1000000007;
constexpr long long MOD9 =  998244353;
constexpr long long INF = numeric_limits<long long>::max() / 8;
constexpr long long LL_MAX = std::numeric_limits<long long>::max();
long long safe_mod(long long n, long long m){if(n >= 0) {return n % m;} else return (n%m + m)%m;}
long long pw(long long x,long long n) {ll ret=1;while(n>0){if(n&1){ret=ret*x;}if(n>>=1){x=x*x;}}return ret;}
template<typename T> T div_ceil(T a,T b){return (a - 1) / b + 1;}
template<typename T> T SUM(const vector<T> &v){T ret{};return(accumulate(v.begin(), v.end(), ret));}
template<typename T> T MAX(const vector<T> &v){return *max_element(v.begin(), v.end());}
template<typename T> T MIN(const vector<T> &v){return *min_element(v.begin(), v.end());}
template<typename T> T pwmod(T x, long long n, long long m) {T ret=1;while(n>0){if(n&1)ret=ret*x%m;x=x*x%m;n>>=1;}return ret%m;}
template<typename T> void rsort(vector<T> &v) {sort(v.begin(), v.end(), greater<T>());}
template<typename T> bool chmax(T &a, const T& b) {if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a, const T& b) {if(a>b){a=b;return true;}return false;}
template<typename T, typename S> pair<T, S> mp(const T &a, const S &b){return make_pair(a, b);}
template<typename T> void uniquify(vector<T> &v){sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());}
template<typename T,typename S> ostream&operator<<(ostream&os,const pair<T,S>&p){os<<"("<<p.first<<", "<<p.second<<")";return os;}
template<typename T,typename S> ostream&operator<<(ostream&os,const map<T,S>&ma){for(auto [a,b]:ma){os<<"("<<a<<", "<<b<<")"<<" ";}return os;}
template<typename T> ostream &operator<<(ostream&os,const set<T>&s){os<<"{";for(auto c:s)os<<c<<" ";os<<"}";return os;}
template<typename T> ostream &operator<<(ostream&os,const vector<T>&v){os<<"[";for(int i=0;i<v.size();i++){os<<v[i]<<(i==v.size()-1?"":" ");}os<<"]";return os;}
template<typename T> vector<int> compress(vector<T> &a){
    int n = a.size(); vector<int> ret(n); vector<T> temp = a;
    sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end());
    for(int i = 0; i < n; i++) ret[i] = lower_bound(a.begin(), a.end(), temp[i]) - a.begin();
    return ret;
}

//#define ONLINE_JUDGE
#ifdef ONLINE_JUDGE
#define dump(x) true
#else
#define dump(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#endif

using mint = modint1000000007;
std::istream &operator>>(std::istream& is, modint1000000007 &m){
    int a; is >> a; m = a;
    return is;
}
std::ostream &operator<<(std::ostream& os, const modint1000000007 &m){
    os << m.val();
    return os;
}
mint operator/(const mint &a, const mint &b){
    return a * b.inv();
}

const int MAX_N = 4000100;
mint fact[MAX_N], fact_inv[MAX_N];
void binom_init(){
    fact[0] = 1;
    fact_inv[0] = 1;
    for(int i = 1;i < MAX_N; i++){
        fact[i] = fact[i-1] * i;
        fact_inv[i] = fact[i].inv();
    }
}
mint binom(int n, int k){
    assert(n >= 0);
    if(k < 0 || k > n) return 0;
    return fact[n] * fact_inv[n-k] * fact_inv[k];
}

void solve(){
    binom_init();
    ll a, b, x, y; cin >> a >> b >> x >> y;
    if((a + x + y) & 1){
        cout << 0 << '\n';
        return;
    }
    mint ans = 0;
    vl kaisu(4, b / 4);
    rep(i, (b + 1) % 4) {
        kaisu[i]++;
    }
    rep(xp, a + b + 1) {
        ll xm = xp - x;
        ll yp = (a - 2 * xp + x + y) / 2;
        ll ym = (a - 2 * xp + x - y) / 2;
        assert(xp + xm + yp + ym == a);
        if(xp < 0 || yp < 0 || xm < 0 || ym < 0) continue;
        vl v = {xp, yp, xm, ym};
        mint temp = 1;
        rep(i, 4){
            if(v[i] + kaisu[i] - 1 < 0) continue;
            assert(v[i] + kaisu[i] - 1 < MAX_N);
            temp *= binom(v[i] + kaisu[i] - 1, v[i]);
        }
        ans += temp;
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);

    solve();

    return 0;
}
0