結果
| 問題 | No.1245 ANDORゲーム(calc) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-10 22:39:03 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 810 bytes |
| 記録 | |
| コンパイル時間 | 3,111 ms |
| コンパイル使用メモリ | 283,972 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2025-11-10 22:39:13 |
| 合計ジャッジ時間 | 10,144 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | WA * 8 RE * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (int i = (int)(s); i < (int)(e); ++i)
int main() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
int N, Q;
cin >> N >> Q;
vector<ll> A(N);
rep(i, 0, N) cin >> A[i];
string S;
cin >> S;
vector score(2, vector<ll>(32));
rep(bit, 0, 32) {
vector<int> now = {0, 1};
vector<ll> res(2, 0);
rep(i, 0, N) {
vector<int> nex(2);
rep(j, 0, 2) {
if (S[i] == '0') nex[j] = ((A[i] >> bit) & 1) & now[j];
else nex[j] = ((A[i] >> bit) & 1) | now[j];
res[j] += abs(now[j] - nex[j]);
now[j] = nex[j];
}
}
rep(j, 0, 2) score[j][bit] = res[j];
}
for (;Q--;) {
ll t;
cin >> t;
ll ans = 0;
rep(i, 0, N) ans += score[(t >> i) & 1][i] << i;
cout << ans << '\n';
}
}