結果

問題 No.1426 Got a Covered OR
ユーザー chocoruskchocorusk
提出日時 2021-03-12 22:07:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 1,789 bytes
コンパイル時間 3,489 ms
コンパイル使用メモリ 186,452 KB
実行使用メモリ 19,712 KB
最終ジャッジ日時 2024-04-22 13:05:41
合計ジャッジ時間 5,017 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
19,072 KB
testcase_01 AC 12 ms
19,200 KB
testcase_02 AC 13 ms
19,200 KB
testcase_03 AC 11 ms
19,200 KB
testcase_04 AC 12 ms
19,200 KB
testcase_05 AC 12 ms
19,072 KB
testcase_06 AC 13 ms
19,072 KB
testcase_07 AC 12 ms
19,072 KB
testcase_08 AC 12 ms
19,072 KB
testcase_09 AC 12 ms
19,200 KB
testcase_10 AC 12 ms
19,200 KB
testcase_11 AC 12 ms
19,072 KB
testcase_12 AC 26 ms
19,328 KB
testcase_13 AC 29 ms
19,584 KB
testcase_14 AC 25 ms
19,328 KB
testcase_15 AC 24 ms
19,328 KB
testcase_16 AC 14 ms
19,072 KB
testcase_17 AC 16 ms
19,328 KB
testcase_18 AC 39 ms
19,456 KB
testcase_19 AC 38 ms
19,456 KB
testcase_20 AC 23 ms
19,328 KB
testcase_21 AC 28 ms
19,328 KB
testcase_22 AC 40 ms
19,712 KB
testcase_23 AC 61 ms
19,456 KB
testcase_24 AC 40 ms
19,584 KB
testcase_25 AC 52 ms
19,456 KB
testcase_26 AC 46 ms
19,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
using mint=modint1000000007;
mint f[2000010], invf[2000010];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i;
    invf[n]=f[n].inv();
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1);
}
mint comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]*invf[x-y];
}
int main()
{
    int n; cin>>n;
    int b[100010];
    for(int i=0; i<n; i++) cin>>b[i];
    int bs=0;
    for(int i=0; i<n; i++){
        if(b[i]==-1) continue;
        if((bs|b[i])!=b[i]){
            cout<<0<<endl;
            return 0;
        }
        bs|=b[i];
    }
    fac(n);
    auto calc=[&](int m, int c, int cpr){
        mint res=0;
        for(int i=0; i<=m; i++){
            mint q=mint(2).pow(m-i);
            mint z=comb(m, i)*(q-1).pow(c-cpr)*q.pow(cpr);
            if(i&1) res-=z;
            else res+=z;
        }
        return res;
    };
    int cpr=0;
    int pr=-1;
    mint ans=1;
    for(int i=0; i<n; i++){
        if(b[i]==-1) continue;
        int c=popcount(b[i]);
        //cout<<calc(i-pr, c, cpr).val()<<" "<<i-pr<<" "<<c<<" "<<cpr<<endl;
        ans*=calc(i-pr, c, cpr);
        pr=i, cpr=c;
    }
    cout<<ans.val()<<endl;
    return 0;
}
0