結果
| 問題 |
No.1245 ANDORゲーム(calc)
|
| コンテスト | |
| ユーザー |
yuusanlondon
|
| 提出日時 | 2020-10-02 22:06:45 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 402 ms / 2,000 ms |
| コード長 | 779 bytes |
| コンパイル時間 | 188 ms |
| コンパイル使用メモリ | 82,348 KB |
| 実行使用メモリ | 100,924 KB |
| 最終ジャッジ日時 | 2024-07-17 13:30:30 |
| 合計ジャッジ時間 | 8,652 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
n,q=map(int,input().split())
a=list(map(int,input().split()))
s=input()
t=list(map(int,input().split()))
score=[]
for i in range(40):
score.append([])
score[-1].append(0)
score[-1].append(0)
for i in range(40):
k=1<<i
current=0
for j in range(n):
if current==0 and s[j]=='1' and k&a[j]:
score[i][0]+=1
current=1
if current==1 and s[j]=='0' and not (k&a[j]):
score[i][0]+=1
current=0
current=1
for j in range(n):
if current==0 and s[j]=='1' and k&a[j]:
score[i][1]+=1
current=1
if current==1 and s[j]=='0' and not (k&a[j]):
score[i][1]+=1
current=0
for i in range(q):
ans=0
for j in range(40):
if t[i]&(1<<j):
ans+=(1<<j)*score[j][1]
else:
ans+=(1<<j)*score[j][0]
print(ans)
yuusanlondon