結果

問題 No.1245 ANDORゲーム(calc)
ユーザー msm1993msm1993
提出日時 2020-10-23 15:30:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 751 bytes
コンパイル時間 1,572 ms
コンパイル使用メモリ 166,012 KB
実行使用メモリ 4,460 KB
最終ジャッジ日時 2023-09-28 15:25:22
合計ジャッジ時間 6,596 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 3 ms
4,384 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 32 ms
4,376 KB
testcase_12 AC 32 ms
4,460 KB
testcase_13 AC 32 ms
4,452 KB
testcase_14 AC 32 ms
4,376 KB
testcase_15 AC 32 ms
4,380 KB
testcase_16 AC 33 ms
4,376 KB
testcase_17 AC 32 ms
4,380 KB
testcase_18 AC 31 ms
4,380 KB
testcase_19 AC 32 ms
4,380 KB
testcase_20 AC 33 ms
4,380 KB
testcase_21 AC 32 ms
4,384 KB
testcase_22 AC 31 ms
4,380 KB
testcase_23 AC 32 ms
4,380 KB
testcase_24 AC 32 ms
4,376 KB
testcase_25 AC 24 ms
4,380 KB
testcase_26 AC 27 ms
4,380 KB
testcase_27 AC 30 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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';
}
	
	
0