結果

問題 No.1426 Got a Covered OR
ユーザー se1ka2se1ka2
提出日時 2021-03-12 22:29:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 250 ms / 2,000 ms
コード長 1,344 bytes
コンパイル時間 561 ms
コンパイル使用メモリ 67,640 KB
実行使用メモリ 29,312 KB
最終ジャッジ日時 2024-04-22 13:32:50
合計ジャッジ時間 2,066 ms
ジャッジサーバーID
(参考情報)
judge5 / 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 1 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 18 ms
8,192 KB
testcase_13 AC 26 ms
8,192 KB
testcase_14 AC 20 ms
6,400 KB
testcase_15 AC 15 ms
7,296 KB
testcase_16 AC 4 ms
5,376 KB
testcase_17 AC 6 ms
5,376 KB
testcase_18 AC 30 ms
5,376 KB
testcase_19 AC 30 ms
5,376 KB
testcase_20 AC 13 ms
5,376 KB
testcase_21 AC 19 ms
5,376 KB
testcase_22 AC 250 ms
29,312 KB
testcase_23 AC 52 ms
5,376 KB
testcase_24 AC 30 ms
5,376 KB
testcase_25 AC 42 ms
5,376 KB
testcase_26 AC 43 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll com[32][32];
ll dp[100005][32];

int main()
{
    int n;
    cin >> n;
    ll b[100005];
    b[0] = 0;
    for(int i = 1; i <= n; i++) cin >> b[i];
    ll ans = 1;
    int l = 0;
    for(int i = 0; i <= 30; i++){
        com[i][0] = 1;
        for(int j = 1; j <= i; j++) com[i][j] = (com[i - 1][j] + com[i - 1][j - 1]) % MOD;
    }
    for(int i = 1; i <= n; i++){
        if(b[i] == -1) continue;
        if((b[i] & b[l]) != b[l]){
            cout << 0 << endl;
            return 0;
        }
        int c = 0;
        int d = 0;
        int x = b[l] ^ b[i];
        for(int j = 0; j < 30; j++){
            c += (x >> j) & 1;
            d += (b[l] >> j) & 1;
        }
        for(int k = 0; k <= i - l; k++){
            for(int j = 0; j <= c; j++) dp[k][j] = 0;
        }
        dp[0][0] = 1;
        for(int k = 1; k <= i - l; k++){
            for(int j = 0; j <= c; j++){
                for(int m = 0; m < j; m++){
                    dp[k][j] = (dp[k][j] + dp[k - 1][m] * com[c - m][j - m] % MOD * (1 << (d + m))) % MOD;
                }
                dp[k][j] = (dp[k][j] + dp[k - 1][j] * ((1 << (d + j)) - 1)) % MOD;
            }
        }
        ans = ans * dp[i - l][c] % MOD;
        l = i;
    }
    cout << ans << endl;
}
0