結果

問題 No.1426 Got a Covered OR
ユーザー あかりきあかりき
提出日時 2021-03-12 22:36:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 274 ms / 2,000 ms
コード長 1,132 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 110,976 KB
最終ジャッジ日時 2024-04-22 13:46:47
合計ジャッジ時間 4,252 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
51,968 KB
testcase_01 AC 41 ms
52,096 KB
testcase_02 AC 42 ms
52,608 KB
testcase_03 AC 42 ms
52,096 KB
testcase_04 AC 42 ms
52,352 KB
testcase_05 AC 42 ms
52,352 KB
testcase_06 AC 42 ms
52,352 KB
testcase_07 AC 42 ms
52,224 KB
testcase_08 AC 42 ms
51,968 KB
testcase_09 AC 42 ms
51,968 KB
testcase_10 AC 43 ms
51,968 KB
testcase_11 AC 43 ms
52,480 KB
testcase_12 AC 130 ms
92,160 KB
testcase_13 AC 154 ms
95,744 KB
testcase_14 AC 143 ms
90,112 KB
testcase_15 AC 127 ms
89,856 KB
testcase_16 AC 94 ms
77,056 KB
testcase_17 AC 117 ms
77,952 KB
testcase_18 AC 219 ms
98,688 KB
testcase_19 AC 216 ms
98,688 KB
testcase_20 AC 139 ms
82,432 KB
testcase_21 AC 163 ms
88,576 KB
testcase_22 AC 141 ms
109,312 KB
testcase_23 AC 274 ms
110,976 KB
testcase_24 AC 159 ms
110,848 KB
testcase_25 AC 263 ms
110,592 KB
testcase_26 AC 269 ms
110,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def cmb(n,r,mod):
  if r<0 or r>n:
    return 0
  r=min(r,n-r)
  return g1[n]*g2[r]*g2[n-r]%mod
 
n=int(input())
b=list(map(int,input().split()))
mod=10**9+7

g1=[1,1]
g2=[1,1]
inverse=[0,1]
 
for i in range(2,n+1):
  g1.append((g1[-1]*i)%mod)
  inverse.append((-inverse[mod%i]*(mod//i))%mod)
  g2.append((g2[-1]*inverse[-1])%mod)

for i in range(n):
  if b[i]!=-1:
    b[i]=format(b[i],'032b')
b=[format(0,'032b')]+b

inv2=pow(2,mod-2,mod)
ct=1
ans=1
p=b[0]
for i in range(1,n+1):
  if b[i]==-1:
    ct+=1
  else:
    ct00=0;ct01=0;ct11=0
    for j in range(32):
      if p[j]=='1' and b[i][j]=='0':
        print(0)
        exit()
      elif p[j]=='0' and b[i][j]=='0':
        ct00+=1
      elif p[j]=='0' and b[i][j]=='1':
        ct01+=1
      else:
        ct11+=1
    x=pow(2,ct,mod)
    y=pow(x,ct11,mod)
    z=pow(x-1,ct01,mod)
    a=(y*z%mod)
    for j in range(1,ct+1):
      x*=inv2
      x%=mod
      y=pow(x,ct11,mod)
      z=pow(x-1,ct01,mod)
      w=y*z
      if j%2==1:
        a-=(w*cmb(ct,j,mod)%mod)
      else:
        a+=(w*cmb(ct,j,mod)%mod)
      a%=mod
    ans*=a
    ans%=mod
    ct=1
    p=b[i]
print(ans)
0