結果

問題 No.1426 Got a Covered OR
ユーザー nok0nok0
提出日時 2021-01-17 11:00:20
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 303 ms / 2,000 ms
コード長 1,388 bytes
コンパイル時間 1,944 ms
コンパイル使用メモリ 86,564 KB
実行使用メモリ 259,500 KB
最終ジャッジ日時 2023-08-19 16:25:05
合計ジャッジ時間 10,358 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 238 ms
259,500 KB
testcase_01 AC 243 ms
259,432 KB
testcase_02 AC 238 ms
259,328 KB
testcase_03 AC 242 ms
258,988 KB
testcase_04 AC 243 ms
259,092 KB
testcase_05 AC 242 ms
259,112 KB
testcase_06 AC 239 ms
259,396 KB
testcase_07 AC 241 ms
259,144 KB
testcase_08 AC 238 ms
259,252 KB
testcase_09 AC 245 ms
259,044 KB
testcase_10 AC 242 ms
259,248 KB
testcase_11 AC 251 ms
259,292 KB
testcase_12 AC 261 ms
259,192 KB
testcase_13 AC 259 ms
259,236 KB
testcase_14 AC 250 ms
259,100 KB
testcase_15 AC 246 ms
258,816 KB
testcase_16 AC 248 ms
259,228 KB
testcase_17 AC 288 ms
259,360 KB
testcase_18 AC 286 ms
259,040 KB
testcase_19 AC 277 ms
259,104 KB
testcase_20 AC 268 ms
259,056 KB
testcase_21 AC 278 ms
259,368 KB
testcase_22 AC 253 ms
259,120 KB
testcase_23 AC 303 ms
259,088 KB
testcase_24 AC 259 ms
259,092 KB
testcase_25 AC 293 ms
259,312 KB
testcase_26 AC 292 ms
259,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math


def popcnt(n):
    c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333)
    c = (c & 0x0F0F0F0F0F0F0F0F) + ((c >> 4) & 0x0F0F0F0F0F0F0F0F)
    c = (c & 0x00FF00FF00FF00FF) + ((c >> 8) & 0x00FF00FF00FF00FF)
    c = (c & 0x0000FFFF0000FFFF) + ((c >> 16) & 0x0000FFFF0000FFFF)
    c = (c & 0x00000000FFFFFFFF) + ((c >> 32) & 0x00000000FFFFFFFF)
    return c


mod = 1_000_000_007
MAX = 10 ** 6
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, MAX + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)


def COM(n, r):
    if (r < 0) or (n < r):
        return 0
    return fact[n] * factinv[r] * factinv[n - r] % mod


n = int(input())
b = list(map(int, input().split()))
base, cont, res = 0, 0, 1
for v in b:
    if v == -1:
        cont += 1
    else:
        for i in range(30):
            if base >> i & 1 and v >> i & 1 == 0:
                print(0)
                exit()

        a = popcnt(base)
        b = popcnt(v)
        x = b - a
        tmp = 0
        for i in range(0, x + 1):
            tmp += COM(x, i) * pow((pow(2, b - i, mod) - 1), cont + 1, mod) * (-1 if i % 2 else 1)
            tmp %= mod
        res *= tmp
        res %= mod

        cont, base = 0, v

print(res)
0