結果

問題 No.1245 ANDORゲーム(calc)
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-02-24 17:43:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 201 ms / 2,000 ms
コード長 516 bytes
コンパイル時間 238 ms
コンパイル使用メモリ 81,824 KB
実行使用メモリ 100,340 KB
最終ジャッジ日時 2023-10-24 23:30:43
合計ジャッジ時間 8,659 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,568 KB
testcase_01 AC 35 ms
53,568 KB
testcase_02 AC 35 ms
53,568 KB
testcase_03 AC 34 ms
53,568 KB
testcase_04 AC 36 ms
53,568 KB
testcase_05 AC 34 ms
53,568 KB
testcase_06 AC 35 ms
53,568 KB
testcase_07 AC 57 ms
68,800 KB
testcase_08 AC 56 ms
66,752 KB
testcase_09 AC 57 ms
68,800 KB
testcase_10 AC 61 ms
68,800 KB
testcase_11 AC 189 ms
95,480 KB
testcase_12 AC 188 ms
96,008 KB
testcase_13 AC 187 ms
95,996 KB
testcase_14 AC 189 ms
95,984 KB
testcase_15 AC 187 ms
96,008 KB
testcase_16 AC 201 ms
96,008 KB
testcase_17 AC 186 ms
97,076 KB
testcase_18 AC 184 ms
97,400 KB
testcase_19 AC 197 ms
97,040 KB
testcase_20 AC 185 ms
96,404 KB
testcase_21 AC 185 ms
97,268 KB
testcase_22 AC 188 ms
97,256 KB
testcase_23 AC 185 ms
96,476 KB
testcase_24 AC 199 ms
96,452 KB
testcase_25 AC 145 ms
100,340 KB
testcase_26 AC 156 ms
100,340 KB
testcase_27 AC 181 ms
98,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,q=map(int,input().split())
a=list(map(int,input().split()))
s=input()
tary=list(map(int,input().split()))
now1=2**30-1
now0=0
ary1=[0]*30
ary0=[0]*30
for ai,si in zip(a,list(s)):
  pre1=now1
  pre0=now0
  if si=='0':
    now1&=ai
    now0&=ai
  else:
    now1|=ai
    now0|=ai
  for i in range(30):
    bit=1<<i
    ary0[i]+=abs((now0&bit)-(pre0&bit))
    ary1[i]+=abs((now1&bit)-(pre1&bit))
for t in tary:
  tmp=0
  for i in range(30):
    if (t>>i)&1:
      tmp+=ary1[i]
    else:
      tmp+=ary0[i]
  print(tmp)
0