結果
| 問題 |
No.1245 ANDORゲーム(calc)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-21 00:08:46 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 36 ms / 2,000 ms |
| コード長 | 751 bytes |
| コンパイル時間 | 2,223 ms |
| コンパイル使用メモリ | 193,852 KB |
| 最終ジャッジ日時 | 2025-01-15 12:04:34 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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';
}