結果

問題 No.1245 ANDORゲーム(calc)
ユーザー 夜
提出日時 2020-11-10 20:08:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 238 ms / 2,000 ms
コード長 1,075 bytes
コンパイル時間 770 ms
コンパイル使用メモリ 93,980 KB
実行使用メモリ 4,456 KB
最終ジャッジ日時 2023-09-30 00:10:54
合計ジャッジ時間 8,548 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 5 ms
4,376 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 6 ms
4,376 KB
testcase_10 AC 7 ms
4,376 KB
testcase_11 AC 230 ms
4,380 KB
testcase_12 AC 227 ms
4,376 KB
testcase_13 AC 231 ms
4,380 KB
testcase_14 AC 228 ms
4,376 KB
testcase_15 AC 232 ms
4,380 KB
testcase_16 AC 231 ms
4,380 KB
testcase_17 AC 215 ms
4,376 KB
testcase_18 AC 207 ms
4,380 KB
testcase_19 AC 205 ms
4,384 KB
testcase_20 AC 223 ms
4,376 KB
testcase_21 AC 222 ms
4,380 KB
testcase_22 AC 217 ms
4,376 KB
testcase_23 AC 238 ms
4,456 KB
testcase_24 AC 227 ms
4,380 KB
testcase_25 AC 171 ms
4,380 KB
testcase_26 AC 176 ms
4,456 KB
testcase_27 AC 188 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
bitset<32> a[100010];
long long score[32][2] = {};
int main() {
	long long n, q;
	string s;
	cin >> n >> q;
	for (int i = 0; i < n; i++) {
		long long a1;
		cin >> a1;
		a[i] = a1;
	}
	cin >> s;
	for (int i = 0; i < 32; i++) {
		for (int j = 0; j < 2; j++) {
			bool bo = j;
			for (int k = 0; k < n; k++) {
				if (s[k] == '0') {
					if (bo && !a[k][i]) {
						score[i][j] += (1 << i);
						bo = false;
					}
				}
				else {
					if (!bo && a[k][i]) {
						score[i][j] += (1 << i);
						bo = true;
					}
				}
			}
		}
	}
	for (int i = 0; i < q; i++) {
		bitset<32> t;
		long long t1;
		cin >> t1;
		t = t1;
		long long ans = 0;
		for (int j = 0; j < 32; j++) {
			ans += score[j][t[j]];
		}
		cout << ans << endl;
	}
}
0