結果

問題 No.1410 A lot of Bit Operations
ユーザー chineristACchineristAC
提出日時 2021-02-26 22:35:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 977 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 82,452 KB
実行使用メモリ 54,128 KB
最終ジャッジ日時 2024-04-10 13:15:18
合計ジャッジ時間 3,005 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
52,924 KB
testcase_01 AC 32 ms
53,584 KB
testcase_02 AC 33 ms
52,532 KB
testcase_03 AC 33 ms
52,824 KB
testcase_04 AC 34 ms
54,108 KB
testcase_05 AC 31 ms
52,808 KB
testcase_06 AC 31 ms
52,480 KB
testcase_07 AC 30 ms
52,428 KB
testcase_08 AC 33 ms
52,740 KB
testcase_09 AC 32 ms
53,204 KB
testcase_10 AC 31 ms
52,688 KB
testcase_11 AC 31 ms
53,400 KB
testcase_12 AC 32 ms
52,892 KB
testcase_13 AC 32 ms
52,888 KB
testcase_14 AC 32 ms
53,164 KB
testcase_15 AC 32 ms
53,020 KB
testcase_16 AC 32 ms
53,264 KB
testcase_17 AC 31 ms
52,488 KB
testcase_18 AC 31 ms
52,464 KB
testcase_19 AC 34 ms
54,128 KB
testcase_20 AC 33 ms
52,824 KB
testcase_21 AC 33 ms
52,828 KB
testcase_22 AC 31 ms
53,348 KB
testcase_23 AC 32 ms
52,756 KB
testcase_24 AC 30 ms
53,124 KB
testcase_25 AC 31 ms
53,148 KB
testcase_26 AC 31 ms
52,524 KB
testcase_27 AC 31 ms
52,124 KB
testcase_28 AC 32 ms
52,868 KB
testcase_29 AC 32 ms
52,504 KB
testcase_30 AC 33 ms
51,992 KB
testcase_31 AC 34 ms
52,744 KB
testcase_32 AC 33 ms
52,268 KB
testcase_33 AC 32 ms
53,444 KB
testcase_34 AC 30 ms
53,224 KB
testcase_35 AC 31 ms
52,264 KB
testcase_36 AC 31 ms
52,208 KB
testcase_37 AC 31 ms
53,448 KB
testcase_38 AC 30 ms
53,428 KB
testcase_39 AC 32 ms
52,988 KB
testcase_40 AC 31 ms
52,248 KB
testcase_41 AC 31 ms
53,212 KB
testcase_42 AC 31 ms
53,092 KB
testcase_43 AC 33 ms
53,352 KB
testcase_44 AC 34 ms
52,884 KB
testcase_45 AC 34 ms
53,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def popcount(x):
    x = x - ((x >> 1) & 0x55555555)
    x = (x & 0x33333333) + ((x >> 2) & 0x33333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    return x & 0x0000007f

N = int(input())
K = input()
mod = 10**9+7

def solve(S,N):
    if N==0:
        return 1
    res = 0
    for l in range(4):
        s_l = S>>l & 1
        s15_l = (15-S)>>l & 1

        if N==1:
            res += abs(s15_l-s_l)+1
            continue

        p = popcount(S)
        A = s_l * pow(2,3*N-3,mod) + p * pow(2,2*N-4,mod) * (pow(2,N-1,mod)-1)
        A %= mod

        q = popcount(15-S)
        B = s15_l * pow(2,3*N-3,mod) + q * pow(2,2*N-4,mod) * (pow(2,N-1,mod)-1)

        if s_l > s15_l:
            res += A-B+pow(2,2*N-2,mod)
            res %= mod
        else:
            res += B-A+pow(2,2*N-2,mod)
            res %= mod

    return res

res = 0
for i in range(8):
    if K[i]=="o":
        res += solve(i,N)
        res %= mod

print(res)
0