結果
| 問題 | 
                            No.1426 Got a Covered OR
                             | 
                    
| コンテスト | |
| ユーザー | 
                             nok0
                         | 
                    
| 提出日時 | 2021-01-17 10:57:02 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,155 bytes | 
| コンパイル時間 | 168 ms | 
| コンパイル使用メモリ | 82,048 KB | 
| 実行使用メモリ | 266,736 KB | 
| 最終ジャッジ日時 | 2024-11-29 10:12:08 | 
| 合計ジャッジ時間 | 19,128 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 11 WA * 5 RE * 3 TLE * 5 | 
ソースコード
import math
mod = 1_000_000_007
def popcnt(n):
    c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333)
    c = (c & 0x0F0F0F0F0F0F0F0F) + ((c >> 4) & 0x0F0F0F0F0F0F0F0F)
    c = (c & 0x00FF00FF00FF00FF) + ((c >> 8) & 0x00FF00FF00FF00FF)
    c = (c & 0x0000FFFF0000FFFF) + ((c >> 16) & 0x0000FFFF0000FFFF)
    c = (c & 0x00000000FFFFFFFF) + ((c >> 32) & 0x00000000FFFFFFFF)
    return c
def COM(n, r):
    if n < r:
        return 0
    return math.factorial(n) // math.factorial(r) // math.factorial(n - r) % mod
n = int(input())
b = list(map(int, input().split()))
base, cont, res = 0, 0, 1
for v in b:
    if v == -1:
        cont += 1
    else:
        for i in range(30):
            if base >> i & 1 and v >> i & 1 == 0:
                print(0)
                exit()
        a = popcnt(base)
        b = popcnt(v)
        x = b - a
        tmp = 0
        for i in range(0, x + 1):
            tmp += COM(x, i) * pow((pow(2, b - i, mod) - 1), cont + 1, mod) * (-1 if i % 2 else 1)
            tmp %= mod
        res *= tmp
        cont, base = 0, v
print(res)
            
            
            
        
            
nok0