結果

問題 No.1426 Got a Covered OR
ユーザー convexineqconvexineq
提出日時 2021-03-12 22:42:33
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,444 bytes
コンパイル時間 338 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 96,640 KB
最終ジャッジ日時 2024-04-22 14:01:33
合計ジャッジ時間 3,630 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
61,440 KB
testcase_01 AC 49 ms
61,312 KB
testcase_02 AC 48 ms
61,440 KB
testcase_03 AC 52 ms
61,440 KB
testcase_04 WA -
testcase_05 AC 48 ms
61,440 KB
testcase_06 WA -
testcase_07 AC 49 ms
61,568 KB
testcase_08 AC 48 ms
61,440 KB
testcase_09 AC 49 ms
61,440 KB
testcase_10 AC 50 ms
61,184 KB
testcase_11 AC 50 ms
61,440 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 93 ms
88,960 KB
testcase_23 WA -
testcase_24 AC 75 ms
88,448 KB
testcase_25 WA -
testcase_26 AC 126 ms
96,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

SIZE=10**5+1; MOD=10**9+7 #998244353 #ここを変更する

inv = [0]*SIZE  # inv[j] = j^{-1} mod MOD
fac = [0]*SIZE  # fac[j] = j! mod MOD
finv = [0]*SIZE # finv[j] = (j!)^{-1} mod MOD
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2,SIZE):
    fac[i] = fac[i-1]*i%MOD
finv[-1] = pow(fac[-1],MOD-2,MOD)
for i in range(SIZE-1,0,-1):
    finv[i-1] = finv[i]*i%MOD
    inv[i] = finv[i]*fac[i-1]%MOD

def choose(n,r): # nCk mod MOD の計算
    if 0 <= r <= n:
        return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
    else:
        return 0


def popcount(i): # i < 2^32
    i = i - ((i >> 1) & 0x55555555)
    i = (i & 0x33333333) + ((i >> 2) & 0x33333333)
    return (((i + (i >> 4) & 0xF0F0F0F) * 0x1010101) & 0xffffffff) >> 24

n = int(input())
*a, = map(int,input().split())
p2 = [1]*(n+100)
for i in range(1,n+100):
    p2[i] = p2[i-1]*2%MOD

def check(c,x,y):
    r = 0
    sgn = 1
    for i in range(1,c+1)[::-1]:
        r += sgn*choose(c,i)*pow(p2[i],x,MOD)%MOD*pow(p2[i]-1,y,MOD)
        r %= MOD
        sgn *= -1
    #print(c,x,y,r)
    return r


v = c = 0
ans = 1
for ai in a:
    c += 1
    if ai == -1:
        continue
    else:
        if v|ai != ai:
            ans = 0
            break
        x = popcount(v&ai)
        y = popcount(v^ai)
        #print(x,y)
        ans *= check(c,x,y)
        ans %= MOD
        c = 0
        v = ai
    #print(ans)
if c:
    ans *= pow(p2[30]-1,c,MOD)
    ans %= MOD

print(ans)
0