結果

問題 No.1245 ANDORゲーム(calc)
ユーザー Example0911Example0911
提出日時 2020-10-03 16:20:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 277 ms / 2,000 ms
コード長 961 bytes
コンパイル時間 1,656 ms
コンパイル使用メモリ 171,152 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 05:22:07
合計ジャッジ時間 8,480 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 7 ms
4,376 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 6 ms
4,380 KB
testcase_10 AC 8 ms
4,376 KB
testcase_11 AC 271 ms
4,376 KB
testcase_12 AC 277 ms
4,380 KB
testcase_13 AC 272 ms
4,376 KB
testcase_14 AC 268 ms
4,380 KB
testcase_15 AC 270 ms
4,380 KB
testcase_16 AC 267 ms
4,376 KB
testcase_17 AC 253 ms
4,380 KB
testcase_18 AC 245 ms
4,376 KB
testcase_19 AC 242 ms
4,376 KB
testcase_20 AC 256 ms
4,376 KB
testcase_21 AC 249 ms
4,380 KB
testcase_22 AC 240 ms
4,380 KB
testcase_23 AC 261 ms
4,380 KB
testcase_24 AC 260 ms
4,380 KB
testcase_25 AC 200 ms
4,376 KB
testcase_26 AC 204 ms
4,376 KB
testcase_27 AC 225 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

//#define int long long
#define ll long long

ll INF = (1LL << 60);
int mod = 100000;
using P = pair<int, int>;


signed main() {
	int N, Q; cin >> N >> Q;
	vector<int>A(N); for (int i = 0; i < N; i++)cin >> A[i];
	string S; cin >> S;
	vector<vector<ll>>ans(30, vector<ll>(2));
	for (int i = 0; i < 30; i++) {
		for (int j = 0; j < 2; j++) {
			bool now = j;
			for (int k = 0; k < N; k++) {
				bool now2 = (A[k] & (1 << i));
				if (S[k] == '0') {
					bool nv = (now & now2);
					if (nv != now) {
						ans[i][j]++;
					}
					now = nv;
				}
				else {
					bool nv = (now | now2);
					if (nv != now)ans[i][j]++;
					now = nv;
				}
			}
		}
	}
	for (int _ = 0; _ < Q; _++) {
		ll t; cin >> t;
		ll res = 0;
		for (int i = 0; i < 30; i++) {
			bool now = (t & (1LL << i));
			res += ans[i][now] * (1LL << i);
		}
		cout << res << endl;
	}
	return 0;
}
0