結果

問題 No.1426 Got a Covered OR
ユーザー 👑 箱星箱星
提出日時 2020-12-11 23:00:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,561 bytes
コンパイル時間 721 ms
コンパイル使用メモリ 74,456 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 01:46:42
合計ジャッジ時間 2,279 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 20 ms
4,348 KB
testcase_23 WA -
testcase_24 AC 29 ms
4,348 KB
testcase_25 WA -
testcase_26 AC 53 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> bool chmax(T& m, const T q) { if (m < q) { m = q; return true; } else return false; }
template<typename T> bool chmin(T& m, const T q) { if (q < m) { m = q; return true; } else return false; }

const ll MOD = 1000000007;
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll modinv(ll i, ll mod) {
    return modpow(i, mod - 2, mod);
}

ll fact(ll n, ll mod) {
    ll ans = 1;
    rep(i, n) {
        ans = ans * (i + 1) % mod;
    }
    return ans;
}

ll comb(ll n, ll a, ll mod) {
    ll ans = 1, denom = 1;
    rep(i, a) {
        ans = ans * (n - i) % mod;
        denom = denom * (i + 1) % mod;
    }
    ans = ans * modinv(denom, mod) % mod;
    return ans;
}

ll pow2[35];

ll calc(ll a, ll b, ll c) {
    ll ret = 0;
    for (int i = 0; i <= b; i++) {
        ll v = comb(b, i, MOD) * modpow(pow2[b + c - i] - 1, a, MOD) % MOD;
        if (i % 2 == 0) {
            ret += v;
            ret %= MOD;
        }
        else {
            ret += MOD - v;
            ret %= MOD;
        }
    }
    return ret;
}

int main()
{
    int i;
    pow2[0] = 1;
    for (i = 0; i < 34; i++) {
        pow2[i + 1] = pow2[i] * 2;
    }
    int n;
    cin >> n;
    vector<ll> b(n, 0);
    for (i = 0; i < n; i++) {
        cin >> b[i];
    }
    ll prev = 0;
    ll streak = 0;
    ll ans = 1;
    for (i = 0; i < n; i++) {
        if (b[i] == -1)
        {
            streak++;
        }
        else {
            ll c01 = 0;
            ll c11 = 0;
            for (int j = 0; j < 32; j++) {
                ll x = (prev >> j) % 2;
                ll y = (b[i] >> j) % 2;
                if (x == 0 && y == 1)
                {
                    c01++;
                }
                else if (x == 1 && y == 1)
                {
                    c11++;
                }
                else if (x == 1 && y == 0)
                {
                    cout << 0 << "\n";
                    return 0;
                }
            }
            ans *= calc(streak + 1, c01, c11);
            prev = b[i];
            streak = 0;
        }
    }
    cout << ans << "\n";
    return 0;
}
0