結果
| 問題 | No.1426 Got a Covered OR |
| コンテスト | |
| ユーザー |
yuusanlondon
|
| 提出日時 | 2021-03-12 22:36:20 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 480 ms / 2,000 ms |
| コード長 | 892 bytes |
| 記録 | |
| コンパイル時間 | 371 ms |
| コンパイル使用メモリ | 85,120 KB |
| 実行使用メモリ | 108,416 KB |
| 最終ジャッジ日時 | 2026-05-01 23:23:30 |
| 合計ジャッジ時間 | 4,328 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
n=int(input())
a=list(map(int,input().split()))
prev=0
count=0
MOD=10**9+7
factorials=[1]
temp=1
s=10**5
for i in range(1,s+1):
temp=(temp*i)%MOD
factorials.append(temp)
inverses=[]
for i in range(s+1):
inverses.append(pow(factorials[i],MOD-2,MOD))
ans=1
for _ in range(n):
count+=1
if a[_]!=-1:
bitcount1=0
bitcount2=0
fail=0
for i in range(30):
if prev&1<<i and not a[_]&1<<i:
fail=1
elif prev&1<<i:
bitcount2+=1
elif a[_]&1<<i:
bitcount1+=1
if fail:
print(0)
exit()
tmp0=0
for i in range(count+1):
tmp=pow(-1,count-i)
tmp=(tmp*factorials[count]*inverses[i]*inverses[count-i])%MOD
tmp2=1
for j in range(bitcount1):
tmp2=(tmp2*(pow(2,i,MOD)-1))%MOD
tmp0=(tmp0+tmp*tmp2*pow(2,bitcount2*i,MOD))%MOD
ans=(ans*tmp0)%MOD
count=0
prev=a[_]
print(ans)
yuusanlondon