結果
| 問題 | 
                            No.1245 ANDORゲーム(calc)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             tktk_snsn
                         | 
                    
| 提出日時 | 2020-10-02 22:25:17 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 895 bytes | 
| コンパイル時間 | 81 ms | 
| コンパイル使用メモリ | 12,800 KB | 
| 実行使用メモリ | 33,716 KB | 
| 最終ジャッジ日時 | 2024-07-17 21:51:55 | 
| 合計ジャッジ時間 | 5,057 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 8 TLE * 3 -- * 14 | 
ソースコード
n, q = map(int, input().split())
A = list(map(int, input().split()))
S = input()
T = list(map(int, input().split()))
memo0 = []
memo1 = []
for i in range(32):
    vals = [(a >> i) & 1 for a in A]
    weight = 1 << i
    # i番目のbitが0のとき
    x = 0
    score = 0
    for s, v in zip(S, vals):
        if s == "0":
            xx = x & v
        else:
            xx = x | v
        if xx != x:
            score += weight
            x = xx
    memo0.append(score)
    # i番目のbitが0のとき
    x = 1
    score = 0
    for s, v in zip(S, vals):
        if s == "0":
            xx = x & v
        else:
            xx = x | v
        if xx != x:
            score += weight
            x = xx
    memo1.append(score)
for t in T:
    ans = 0
    for i in range(32):
        if (t >> i) & 1:
            ans += memo1[i]
        else:
            ans += memo0[i]
    print(ans)
            
            
            
        
            
tktk_snsn