結果
| 問題 | 
                            No.1245 ANDORゲーム(calc)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             msm1993
                         | 
                    
| 提出日時 | 2020-10-23 15:30:08 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 31 ms / 2,000 ms | 
| コード長 | 751 bytes | 
| コンパイル時間 | 1,341 ms | 
| コンパイル使用メモリ | 167,616 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-21 10:07:04 | 
| 合計ジャッジ時間 | 5,294 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 25 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
constexpr int kN = int(1E5 + 10);
int a[kN], t[kN];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q, x = 0, y = 0;
	ll tot = 0;
	string s;
	cin >> n >> q;
	for (int i = 1; i <= n; i++) cin >> a[i];
	cin >> s;
	for (int i = 1; i <= q; i++) cin >> t[i];
	reverse(s.begin(), s.end());
	reverse(a + 1, a + n + 1);
	for (int i = 1; i <= n; i++) if (s[i - 1] == '0') {
		x |= ~a[i];
		tot += y ^ (y & ~x);
		y &= ~x;
	}
	else {
		y |= a[i];
		tot += x ^ (x & ~y);
		x &= ~y;
	}
	//cout << x << ' ' << y << ' ' << tot << '\n';
	//for (int i = 1; i <= q; i++) cout << t[i] << '\n';
	for (int i = 1; i <= q; i++) cout << tot + (t[i] & x) + (~t[i] & y) << '\n';
}
	
	
            
            
            
        
            
msm1993