結果

問題 No.1410 A lot of Bit Operations
ユーザー googol_S0googol_S0
提出日時 2021-02-26 21:59:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 778 bytes
コンパイル時間 611 ms
コンパイル使用メモリ 82,624 KB
実行使用メモリ 54,416 KB
最終ジャッジ日時 2024-04-10 12:41:13
合計ジャッジ時間 3,300 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,592 KB
testcase_01 AC 37 ms
52,808 KB
testcase_02 AC 37 ms
52,960 KB
testcase_03 AC 38 ms
53,484 KB
testcase_04 AC 38 ms
54,096 KB
testcase_05 AC 38 ms
53,016 KB
testcase_06 AC 37 ms
52,372 KB
testcase_07 AC 38 ms
52,828 KB
testcase_08 AC 37 ms
52,652 KB
testcase_09 AC 37 ms
53,256 KB
testcase_10 AC 37 ms
52,448 KB
testcase_11 AC 40 ms
52,192 KB
testcase_12 AC 37 ms
53,532 KB
testcase_13 AC 38 ms
52,704 KB
testcase_14 AC 38 ms
52,540 KB
testcase_15 AC 37 ms
53,140 KB
testcase_16 AC 37 ms
52,724 KB
testcase_17 AC 37 ms
52,488 KB
testcase_18 AC 36 ms
53,324 KB
testcase_19 AC 38 ms
52,736 KB
testcase_20 AC 38 ms
53,312 KB
testcase_21 AC 37 ms
52,804 KB
testcase_22 AC 38 ms
52,528 KB
testcase_23 AC 37 ms
53,284 KB
testcase_24 AC 38 ms
54,416 KB
testcase_25 AC 38 ms
52,460 KB
testcase_26 AC 37 ms
52,560 KB
testcase_27 AC 37 ms
53,492 KB
testcase_28 AC 38 ms
53,024 KB
testcase_29 AC 38 ms
52,464 KB
testcase_30 AC 37 ms
52,932 KB
testcase_31 AC 38 ms
52,660 KB
testcase_32 AC 38 ms
52,872 KB
testcase_33 AC 37 ms
52,544 KB
testcase_34 AC 37 ms
52,480 KB
testcase_35 AC 37 ms
53,268 KB
testcase_36 AC 37 ms
52,784 KB
testcase_37 AC 37 ms
52,640 KB
testcase_38 AC 37 ms
53,896 KB
testcase_39 AC 37 ms
53,316 KB
testcase_40 AC 37 ms
53,140 KB
testcase_41 AC 37 ms
52,592 KB
testcase_42 AC 37 ms
54,144 KB
testcase_43 AC 37 ms
52,804 KB
testcase_44 AC 37 ms
53,352 KB
testcase_45 AC 38 ms
52,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
K=input()
if N<=2:
  ANS=0
  for i in range(8):
    if K[i]=='-':
      continue
    X=[(i&(1<<j))>>j for j in range(4)]
    def f(x,y):
      r=0
      for i in range(N):
        r*=2
        r+=X[((x&(1<<i))>>i)*2+((y&(1<<i))>>i)]
      return r
    
    for x in range(1<<N):
      for y in range(1<<N):
        for z in range(1<<N):
          if (f(x,y)-z)*((1-f(x,y))-z)<=0:
            ANS+=1
  print(ANS%(10**9+7))
  exit()
mod=10**9+7
ANS=0
t=pow(2,2*N,mod)
x=(pow(2,N-1,mod)-1)%mod
for i in range(8):
  if K[i]=='-':
    continue
  X=[(i&(1<<j))>>j for j in range(4)]
  Y=[X.count(0),X.count(1)]
  ANS+=t
  ANS+=x*pow(4,N-2,mod)*(Y[0]*Y[0]+Y[1]*Y[1])%mod
  ANS-=x*pow(4,N-2,mod)*(Y[0]*Y[1]+Y[1]*Y[0])%mod
  ANS+=pow(4,N,mod)*pow(2,N-1,mod)
print(ANS%mod)
0