結果

問題 No.1410 A lot of Bit Operations
ユーザー googol_S0
提出日時 2021-02-26 21:56:52
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 631 bytes
コンパイル時間 219 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 52,480 KB
最終ジャッジ日時 2024-10-02 14:37:42
合計ジャッジ時間 3,310 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 42 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
K=input()
if N==0:
  ANS=0
  for i in range(8):
    if K[i]=='-':
      continue
    X=[(i&(1<<j))>>j for j in range(4)]
    for x in range(2):
      for y in range(2):
        for z in range(2):
          if (X[x*2+y]-z)*((1-X[x*2+y])-z)<=0:
            ANS+=1
  print(ANS)
  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