結果

問題 No.1426 Got a Covered OR
ユーザー nok0nok0
提出日時 2021-01-17 11:11:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,473 bytes
コンパイル時間 346 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 32,400 KB
最終ジャッジ日時 2024-05-06 23:38:46
合計ジャッジ時間 7,924 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


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 ** 5 + 10
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(readline())
b = list(map(int, readline().split()))
base, cont, res = 0, 0, 1
print(b)
for v in b:
    if v == -1:
        cont += 1
    else:
        if (v | (base ^ v)) != v:
            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