結果

問題 No.1426 Got a Covered OR
ユーザー se1ka2se1ka2
提出日時 2021-03-12 22:28:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,344 bytes
コンパイル時間 559 ms
コンパイル使用メモリ 67,892 KB
実行使用メモリ 28,936 KB
最終ジャッジ日時 2024-04-22 13:31:35
合計ジャッジ時間 2,103 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 15 ms
8,592 KB
testcase_13 AC 27 ms
9,036 KB
testcase_14 AC 19 ms
7,628 KB
testcase_15 AC 14 ms
8,120 KB
testcase_16 AC 4 ms
6,944 KB
testcase_17 AC 6 ms
6,940 KB
testcase_18 AC 30 ms
6,944 KB
testcase_19 AC 30 ms
6,940 KB
testcase_20 AC 12 ms
6,940 KB
testcase_21 AC 18 ms
6,940 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 30 ms
6,944 KB
testcase_25 AC 42 ms
6,944 KB
testcase_26 AC 43 ms
6,940 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;
    int 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