結果

問題 No.1426 Got a Covered OR
ユーザー nok0nok0
提出日時 2021-01-17 11:00:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 282 ms / 2,000 ms
コード長 1,388 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 82,512 KB
実行使用メモリ 248,480 KB
最終ジャッジ日時 2024-05-06 23:23:54
合計ジャッジ時間 8,156 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 234 ms
247,340 KB
testcase_01 AC 223 ms
247,132 KB
testcase_02 AC 227 ms
246,796 KB
testcase_03 AC 224 ms
247,448 KB
testcase_04 AC 232 ms
246,696 KB
testcase_05 AC 226 ms
247,064 KB
testcase_06 AC 228 ms
247,252 KB
testcase_07 AC 225 ms
247,104 KB
testcase_08 AC 223 ms
247,908 KB
testcase_09 AC 218 ms
246,968 KB
testcase_10 AC 227 ms
246,880 KB
testcase_11 AC 225 ms
247,224 KB
testcase_12 AC 282 ms
248,136 KB
testcase_13 AC 235 ms
247,040 KB
testcase_14 AC 245 ms
247,412 KB
testcase_15 AC 236 ms
247,464 KB
testcase_16 AC 227 ms
247,768 KB
testcase_17 AC 235 ms
247,372 KB
testcase_18 AC 270 ms
247,012 KB
testcase_19 AC 265 ms
246,740 KB
testcase_20 AC 246 ms
247,036 KB
testcase_21 AC 249 ms
247,384 KB
testcase_22 AC 235 ms
247,584 KB
testcase_23 AC 281 ms
246,768 KB
testcase_24 AC 241 ms
247,296 KB
testcase_25 AC 271 ms
247,316 KB
testcase_26 AC 274 ms
248,480 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