Submission #7510385


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

#define int long long
// #define double long double
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
#define rAll(a) (a).rbegin(), (a).rend()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CCIN(...)                                                              \
    char __VA_ARGS__;                                                          \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef pair<ll, ll> PL;
typedef vector<PL> VPL;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<bool> VB;
typedef vector<double> VD;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 5e18;
// const double PI = atan(1.0) * 4.0;
const ll dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
#define PI 3.141592653589793238

template <int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if(val < 0) v += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; }
    constexpr Fp operator+(const Fp &r) const noexcept {
        return Fp(*this) += r;
    }
    constexpr Fp operator-(const Fp &r) const noexcept {
        return Fp(*this) -= r;
    }
    constexpr Fp operator*(const Fp &r) const noexcept {
        return Fp(*this) *= r;
    }
    constexpr Fp operator/(const Fp &r) const noexcept {
        return Fp(*this) /= r;
    }
    constexpr Fp &operator+=(const Fp &r) noexcept {
        val += r.val;
        if(val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp &operator-=(const Fp &r) noexcept {
        val -= r.val;
        if(val < 0) val += MOD;
        return *this;
    }
    constexpr Fp &operator*=(const Fp &r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp &operator/=(const Fp &r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while(b) {
            long long t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        val = val * u % MOD;
        if(val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator==(const Fp &r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator!=(const Fp &r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept {
        return os << x.val;
    }
    friend constexpr istream &operator>>(istream &is, Fp<MOD> &x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if(n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if(n & 1) t = t * a;
        return t;
    }
};

using mint = Fp<MOD>;

const ll NMAX = 1e6;
ll fac[NMAX + 1], inv[NMAX + 1], finv[NMAX + 1];

void cominit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    FOR(i, 2, NMAX + 1) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll comb(ll n, ll k) {
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main() {
    cominit();
    LCIN(R, C, X, Y, D, L);
    mint ans = 0;
    REP(i, 3) REP(j, 3) {
        int tx = X - i;
        int ty = Y - j;
        if((i + j) % 2 == 0) {
            ans += (mint)comb(2, i) * comb(2, j) * comb(tx * ty, D + L) * comb(D + L, D);
        } else {
            ans -= (mint)comb(2, i) * comb(2, j) * comb(tx * ty, D + L) * comb(D + L, D);
        }
    }
    ans *= (R - X + 1) * (C - Y + 1);
    cout << ans << "\n";
}

Submission Info

Submission Time
Task D - AtCoder社の冬
User arktan763
Language C++14 (GCC 5.4.1)
Score 0
Code Size 5995 Byte
Status WA
Exec Time 35 ms
Memory 23680 KB

Judge Result

Set Name sub All
Score / Max Score 0 / 100 0 / 1
Status
AC × 24
WA × 1
AC × 51
WA × 1
Set Name Test Cases
sub 00_sample_01E.txt, 00_sample_02E.txt, 00_sample_03E.txt, test_03E.txt, test_04E.txt, test_07E.txt, test_08E.txt, test_11E.txt, test_12E.txt, test_15E.txt, test_16E.txt, test_19E.txt, test_20E.txt, test_23E.txt, test_24E.txt, test_27E.txt, test_28E.txt, test_31E.txt, test_32E.txt, test_36E.txt, test_37E.txt, test_38E.txt, test_39E.txt, test_45E.txt, test_47E.txt
All 00_sample_01E.txt, 00_sample_02E.txt, 00_sample_03E.txt, 00_sample_04.txt, test_01.txt, test_02.txt, test_03E.txt, test_04E.txt, test_05.txt, test_06.txt, test_07E.txt, test_08E.txt, test_09.txt, test_10.txt, test_11E.txt, test_12E.txt, test_13.txt, test_14.txt, test_15E.txt, test_16E.txt, test_17.txt, test_18.txt, test_19E.txt, test_20E.txt, test_21.txt, test_22.txt, test_23E.txt, test_24E.txt, test_25.txt, test_26.txt, test_27E.txt, test_28E.txt, test_29.txt, test_30.txt, test_31E.txt, test_32E.txt, test_33.txt, test_34.txt, test_35.txt, test_36E.txt, test_37E.txt, test_38E.txt, test_39E.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt, test_44.txt, test_45E.txt, test_46.txt, test_47E.txt, test_48.txt
Case Name Status Exec Time Memory
00_sample_01E.txt AC 34 ms 23680 KB
00_sample_02E.txt AC 34 ms 23680 KB
00_sample_03E.txt AC 33 ms 23680 KB
00_sample_04.txt AC 34 ms 23680 KB
test_01.txt AC 33 ms 23680 KB
test_02.txt AC 33 ms 23680 KB
test_03E.txt AC 34 ms 23680 KB
test_04E.txt AC 34 ms 23680 KB
test_05.txt AC 34 ms 23680 KB
test_06.txt AC 34 ms 23680 KB
test_07E.txt AC 34 ms 23680 KB
test_08E.txt AC 34 ms 23680 KB
test_09.txt AC 34 ms 23680 KB
test_10.txt AC 34 ms 23680 KB
test_11E.txt AC 34 ms 23680 KB
test_12E.txt AC 34 ms 23680 KB
test_13.txt AC 34 ms 23680 KB
test_14.txt AC 34 ms 23680 KB
test_15E.txt AC 34 ms 23680 KB
test_16E.txt AC 34 ms 23680 KB
test_17.txt AC 34 ms 23680 KB
test_18.txt AC 34 ms 23680 KB
test_19E.txt AC 34 ms 23680 KB
test_20E.txt AC 34 ms 23680 KB
test_21.txt AC 35 ms 23680 KB
test_22.txt AC 34 ms 23680 KB
test_23E.txt AC 34 ms 23680 KB
test_24E.txt AC 34 ms 23680 KB
test_25.txt AC 34 ms 23680 KB
test_26.txt AC 34 ms 23680 KB
test_27E.txt AC 34 ms 23680 KB
test_28E.txt AC 33 ms 23680 KB
test_29.txt AC 34 ms 23680 KB
test_30.txt AC 34 ms 23680 KB
test_31E.txt AC 34 ms 23680 KB
test_32E.txt AC 33 ms 23680 KB
test_33.txt AC 33 ms 23680 KB
test_34.txt AC 34 ms 23680 KB
test_35.txt AC 34 ms 23680 KB
test_36E.txt AC 34 ms 23680 KB
test_37E.txt AC 34 ms 23680 KB
test_38E.txt AC 34 ms 23680 KB
test_39E.txt WA 34 ms 23680 KB
test_40.txt AC 34 ms 23680 KB
test_41.txt AC 34 ms 23680 KB
test_42.txt AC 34 ms 23680 KB
test_43.txt AC 34 ms 23680 KB
test_44.txt AC 34 ms 23680 KB
test_45E.txt AC 34 ms 23680 KB
test_46.txt AC 34 ms 23680 KB
test_47E.txt AC 34 ms 23680 KB
test_48.txt AC 34 ms 23680 KB