結果

問題 No.1426 Got a Covered OR
ユーザー あかりきあかりき
提出日時 2021-03-12 22:36:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 280 ms / 2,000 ms
コード長 1,132 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 87,180 KB
実行使用メモリ 111,844 KB
最終ジャッジ日時 2023-08-04 15:58:30
合計ジャッジ時間 5,172 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,456 KB
testcase_01 AC 72 ms
71,424 KB
testcase_02 AC 73 ms
71,412 KB
testcase_03 AC 74 ms
71,232 KB
testcase_04 AC 74 ms
71,336 KB
testcase_05 AC 73 ms
71,236 KB
testcase_06 AC 74 ms
71,412 KB
testcase_07 AC 71 ms
71,404 KB
testcase_08 AC 72 ms
71,132 KB
testcase_09 AC 71 ms
71,368 KB
testcase_10 AC 71 ms
71,348 KB
testcase_11 AC 73 ms
71,212 KB
testcase_12 AC 155 ms
93,168 KB
testcase_13 AC 175 ms
97,088 KB
testcase_14 AC 158 ms
91,428 KB
testcase_15 AC 143 ms
91,432 KB
testcase_16 AC 109 ms
77,960 KB
testcase_17 AC 135 ms
79,340 KB
testcase_18 AC 232 ms
99,544 KB
testcase_19 AC 229 ms
99,536 KB
testcase_20 AC 152 ms
83,456 KB
testcase_21 AC 176 ms
89,800 KB
testcase_22 AC 160 ms
110,704 KB
testcase_23 AC 280 ms
101,736 KB
testcase_24 AC 173 ms
111,844 KB
testcase_25 AC 277 ms
111,456 KB
testcase_26 AC 278 ms
111,656 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