結果

問題 No.1426 Got a Covered OR
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-03-12 22:58:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 552 ms / 2,000 ms
コード長 1,164 bytes
コンパイル時間 724 ms
コンパイル使用メモリ 87,208 KB
実行使用メモリ 248,896 KB
最終ジャッジ日時 2023-08-04 16:23:23
合計ジャッジ時間 7,153 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,244 KB
testcase_01 AC 68 ms
71,388 KB
testcase_02 AC 68 ms
71,616 KB
testcase_03 AC 68 ms
71,556 KB
testcase_04 AC 70 ms
71,108 KB
testcase_05 AC 68 ms
71,356 KB
testcase_06 AC 67 ms
71,236 KB
testcase_07 AC 68 ms
71,332 KB
testcase_08 AC 68 ms
71,236 KB
testcase_09 AC 66 ms
71,216 KB
testcase_10 AC 68 ms
71,112 KB
testcase_11 AC 68 ms
71,348 KB
testcase_12 AC 287 ms
247,616 KB
testcase_13 AC 267 ms
241,968 KB
testcase_14 AC 210 ms
228,948 KB
testcase_15 AC 211 ms
245,496 KB
testcase_16 AC 104 ms
96,948 KB
testcase_17 AC 128 ms
106,668 KB
testcase_18 AC 300 ms
243,220 KB
testcase_19 AC 305 ms
243,232 KB
testcase_20 AC 193 ms
159,508 KB
testcase_21 AC 212 ms
210,984 KB
testcase_22 AC 552 ms
246,488 KB
testcase_23 AC 398 ms
248,896 KB
testcase_24 AC 88 ms
89,496 KB
testcase_25 AC 354 ms
248,380 KB
testcase_26 AC 95 ms
90,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
B = list(map(int,input().split()))
mod = 10**9+7

num = 0
for b in B:
    if b != -1:
        if b|num != b:
            print(0)
            exit()
        num = b

fact = [1,1]
finv = [1,1]
inv = [0,1]
pow2 = [1]
for i in range(n*40):
    pow2.append(pow2[-1]*2%mod)
for i in range(2,max(40,n)+5):
    fact.append((fact[-1]*i)%mod)
    inv.append((inv[mod%i]*(mod-mod//i))%mod)
    finv.append((finv[-1]*inv[-1])%mod)
 
def nCr(n,r,mod):
    if r > n:
        return 0
    else: 
        return fact[n]*finv[r]*finv[n-r]%mod

def calc(x,all,le):
    ind = 1
    base = 0

    for i in range(x+1):
        count = 0
        mi = 1
        for j in range(le+1):
            count += mi*nCr(le,j,mod)*pow2[(all-i)*(le-j)]%mod
            count %= mod
            mi *= -1
        base += ind*nCr(x,i,mod)*count%mod
        base %= mod
        ind *= -1

    return base


ans = 1
num = 0
now = 0
for b in B:
    num += 1
    if b == -1:
        continue
    x = b^now
    all = bin(b).count("1")
    c = 0
    for i in range(40):
        if x >> i & 1:
            c += 1
    ans *= calc(c,all,num)
    ans %= mod
    num = 0
    now = b
print(ans)
0