結果

問題 No.1245 ANDORゲーム(calc)
ユーザー 👑 H20H20
提出日時 2022-07-13 14:05:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 729 ms / 2,000 ms
コード長 1,041 bytes
コンパイル時間 487 ms
コンパイル使用メモリ 86,948 KB
実行使用メモリ 99,996 KB
最終ジャッジ日時 2023-09-06 23:11:12
合計ジャッジ時間 17,545 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,428 KB
testcase_01 AC 69 ms
71,384 KB
testcase_02 AC 69 ms
71,636 KB
testcase_03 AC 68 ms
71,232 KB
testcase_04 AC 68 ms
71,340 KB
testcase_05 AC 68 ms
71,124 KB
testcase_06 AC 67 ms
71,632 KB
testcase_07 AC 128 ms
78,224 KB
testcase_08 AC 122 ms
78,060 KB
testcase_09 AC 130 ms
78,284 KB
testcase_10 AC 129 ms
78,232 KB
testcase_11 AC 729 ms
98,920 KB
testcase_12 AC 694 ms
98,104 KB
testcase_13 AC 700 ms
98,020 KB
testcase_14 AC 726 ms
99,348 KB
testcase_15 AC 723 ms
98,280 KB
testcase_16 AC 705 ms
98,528 KB
testcase_17 AC 675 ms
98,040 KB
testcase_18 AC 667 ms
97,892 KB
testcase_19 AC 672 ms
97,936 KB
testcase_20 AC 685 ms
98,336 KB
testcase_21 AC 662 ms
97,900 KB
testcase_22 AC 673 ms
98,216 KB
testcase_23 AC 676 ms
98,424 KB
testcase_24 AC 663 ms
98,592 KB
testcase_25 AC 533 ms
99,732 KB
testcase_26 AC 541 ms
99,996 KB
testcase_27 AC 642 ms
98,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,Q = map(int,input().split())
A = list(map(int,input().split()))
S = list(input())
T = list(map(int,input().split()))
ZEROSUM = [0]*40
ONESUM = [0]*40
zero = [0]*40
one = [1]*40
for i in range(N):
    s = int(S[i])
    a = A[i]
    ab = list(format(a, 'b').zfill(40))[::-1]
    for j in range(40):
        ab[j] = int(ab[j])


    for j in range(40):
        if s==0:
            if zero[j]==1 and ab[j]==0:
                ZEROSUM[j]+=pow(2,j)
            if one[j]==1 and ab[j]==0:
                ONESUM[j]+=pow(2,j)
            zero[j] = zero[j]&ab[j]
            one[j] = one[j]&ab[j]
        else:
            if zero[j]==0 and ab[j]==1:
                ZEROSUM[j]+=pow(2,j)
            if one[j]==0 and ab[j]==1:
                ONESUM[j]+=pow(2,j)
            zero[j] = zero[j]|ab[j]
            one[j] = one[j]|ab[j]


for t in T:
    B = list(format(t, 'b').zfill(40))[::-1]
    ans = 0
    for i,b in enumerate(B):
        if B[i]=='0':
            ans+=ZEROSUM[i]        
        else:
            ans+=ONESUM[i]
    print(ans)
0