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