結果

問題 No.1426 Got a Covered OR
ユーザー yuusanlondonyuusanlondon
提出日時 2021-03-12 22:36:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,145 ms / 2,000 ms
コード長 892 bytes
コンパイル時間 253 ms
コンパイル使用メモリ 82,660 KB
実行使用メモリ 103,484 KB
最終ジャッジ日時 2024-04-22 13:46:53
合計ジャッジ時間 6,755 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
74,880 KB
testcase_01 AC 127 ms
74,368 KB
testcase_02 AC 133 ms
74,496 KB
testcase_03 AC 127 ms
74,368 KB
testcase_04 AC 127 ms
74,624 KB
testcase_05 AC 124 ms
74,496 KB
testcase_06 AC 123 ms
74,368 KB
testcase_07 AC 126 ms
74,624 KB
testcase_08 AC 124 ms
74,624 KB
testcase_09 AC 129 ms
74,368 KB
testcase_10 AC 125 ms
74,624 KB
testcase_11 AC 126 ms
74,240 KB
testcase_12 AC 223 ms
94,336 KB
testcase_13 AC 291 ms
96,768 KB
testcase_14 AC 242 ms
93,696 KB
testcase_15 AC 213 ms
93,696 KB
testcase_16 AC 152 ms
84,352 KB
testcase_17 AC 153 ms
86,400 KB
testcase_18 AC 186 ms
97,636 KB
testcase_19 AC 188 ms
97,864 KB
testcase_20 AC 166 ms
90,484 KB
testcase_21 AC 172 ms
93,312 KB
testcase_22 AC 1,145 ms
101,632 KB
testcase_23 AC 197 ms
103,484 KB
testcase_24 AC 144 ms
96,000 KB
testcase_25 AC 198 ms
102,820 KB
testcase_26 AC 204 ms
102,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)    
0