結果

問題 No.1426 Got a Covered OR
ユーザー merom686merom686
提出日時 2021-03-13 02:39:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 1,409 bytes
コンパイル時間 1,480 ms
コンパイル使用メモリ 100,772 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 16:12:36
合計ジャッジ時間 2,493 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 6 ms
5,376 KB
testcase_13 AC 6 ms
5,376 KB
testcase_14 AC 6 ms
5,376 KB
testcase_15 AC 5 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 12 ms
5,376 KB
testcase_19 AC 12 ms
5,376 KB
testcase_20 AC 6 ms
5,376 KB
testcase_21 AC 7 ms
5,376 KB
testcase_22 AC 9 ms
5,376 KB
testcase_23 AC 18 ms
5,376 KB
testcase_24 AC 11 ms
5,376 KB
testcase_25 AC 16 ms
5,376 KB
testcase_26 AC 16 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <atcoder/modint>
using mint = atcoder::modint1000000007;
using namespace std;
using ll = long long;

vector<mint> f0, f1;
void init(int n) {
    f0.resize(n + 1);
    f0[0] = 1;
    for (int i = 1; i <= n; i++) {
        f0[i] = f0[i - 1] * i;
    }
    f1.resize(n + 1);
    f1[n] = f0[n].inv();
    for (int i = n; i > 0; i--) {
        f1[i - 1] = f1[i] * i;
    }
}
mint fact(int k) {
    return f0[k];
}
mint comb(int n, int k) {
    if (n < k || k < 0) return 0;
    return f0[n] * f1[k] * f1[n - k];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    vector<int> b(n);
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }

    init(30);
    
    mint r = 1;
    int i0 = -1, b0 = 0;
    for (int i = 0; i < n; i++) {
        if (b[i] < 0) continue;

        if (b0 & ~b[i]) {
            cout << 0 << endl;
            exit(0);
        }

        int k = __builtin_popcount(~b0 & b[i]);
        int l = __builtin_popcount(b[i]);

        mint t = 0, sgn = 1;
        for (int j = 0; j <= k; j++) {
            t += mint((1 << (l - j)) - 1).pow(i - i0) * comb(k, j) * sgn;
            sgn *= -1;
        }
        r *= t;

        i0 = i;
        b0 = b[i];
    }

    cout << r.val() << endl;

    return 0;
}
0