結果

問題 No.1426 Got a Covered OR
ユーザー se1ka2se1ka2
提出日時 2021-03-12 22:29:41
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 246 ms / 2,000 ms
コード長 1,344 bytes
コンパイル時間 503 ms
コンパイル使用メモリ 65,220 KB
実行使用メモリ 29,200 KB
最終ジャッジ日時 2023-08-04 15:51:08
合計ジャッジ時間 2,325 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 16 ms
8,004 KB
testcase_13 AC 26 ms
7,900 KB
testcase_14 AC 19 ms
7,848 KB
testcase_15 AC 14 ms
7,792 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 6 ms
4,380 KB
testcase_18 AC 27 ms
4,380 KB
testcase_19 AC 28 ms
4,380 KB
testcase_20 AC 12 ms
4,376 KB
testcase_21 AC 17 ms
4,380 KB
testcase_22 AC 246 ms
29,200 KB
testcase_23 AC 48 ms
4,376 KB
testcase_24 AC 28 ms
4,376 KB
testcase_25 AC 39 ms
4,376 KB
testcase_26 AC 38 ms
4,380 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