結果

問題 No.1245 ANDORゲーム(calc)
ユーザー daikisuyamadaikisuyama
提出日時 2020-10-02 22:48:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 424 ms / 2,000 ms
コード長 1,319 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 86,980 KB
実行使用メモリ 97,040 KB
最終ジャッジ日時 2023-09-24 22:16:17
合計ジャッジ時間 11,275 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,264 KB
testcase_01 AC 75 ms
71,300 KB
testcase_02 AC 77 ms
71,140 KB
testcase_03 AC 76 ms
71,308 KB
testcase_04 AC 80 ms
71,424 KB
testcase_05 AC 77 ms
71,144 KB
testcase_06 AC 77 ms
71,520 KB
testcase_07 AC 124 ms
77,820 KB
testcase_08 AC 104 ms
77,704 KB
testcase_09 AC 118 ms
77,924 KB
testcase_10 AC 117 ms
77,580 KB
testcase_11 AC 418 ms
95,964 KB
testcase_12 AC 419 ms
96,320 KB
testcase_13 AC 424 ms
96,480 KB
testcase_14 AC 423 ms
96,552 KB
testcase_15 AC 418 ms
96,336 KB
testcase_16 AC 418 ms
96,304 KB
testcase_17 AC 377 ms
96,268 KB
testcase_18 AC 353 ms
96,760 KB
testcase_19 AC 365 ms
96,120 KB
testcase_20 AC 384 ms
96,392 KB
testcase_21 AC 371 ms
96,300 KB
testcase_22 AC 365 ms
96,772 KB
testcase_23 AC 383 ms
95,988 KB
testcase_24 AC 360 ms
96,940 KB
testcase_25 AC 262 ms
95,552 KB
testcase_26 AC 265 ms
95,324 KB
testcase_27 AC 287 ms
97,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,q=map(int,input().split())
a=list(map(int,input().split()))
check=[[0,0] for i in range(32)]
s=list(map(int,input()))
for i in range(32):
    #初期状態が0か1か
    for k in range(2):
        x=k
        for j in range(n):
            if (a[j]>>i)&1:
                if s[j]==0:
                    if x==0:
                        check[i][k]+=0
                        x=0
                    else:
                        check[i][k]+=0
                        x=1
                else:
                    if x==0:
                        check[i][k]+=1
                        x=1
                    else:
                        check[i][k]+=0
                        x=1
            else:
                if s[j]==0:
                    if x==0:
                        check[i][k]+=0
                        x=0
                    else:
                        check[i][k]+=1
                        x=0
                else:
                    if x==0:
                        check[i][k]+=0
                        x=0
                    else:
                        check[i][k]+=0
                        x=1
#print(check)
t=list(map(int,input().split()))
for _ in range(q):
    z=t[_]
    ans=0
    for i in range(32):
        ans+=(check[i][(z>>i)&1]*(2**i))
        #print(ans)
    print(ans)
0