結果

問題 No.1426 Got a Covered OR
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-03-12 22:55:34
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,113 bytes
コンパイル時間 463 ms
コンパイル使用メモリ 82,136 KB
実行使用メモリ 110,508 KB
最終ジャッジ日時 2024-04-22 14:22:49
合計ジャッジ時間 6,188 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 38 ms
52,224 KB
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 AC 38 ms
52,224 KB
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 AC 61 ms
79,360 KB
testcase_25 WA -
testcase_26 AC 66 ms
82,432 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]
 
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)*pow(2,(all-i)*(le-j),mod)
            count %= mod
            mi *= -1
        base += ind*nCr(x,i,mod)*count
        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)
    print(ans)
    ans %= mod
    num = 0
    now = b
print(ans)
0