結果
| 問題 |
No.1245 ANDORゲーム(calc)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-11-10 20:08:53 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 243 ms / 2,000 ms |
| コード長 | 1,075 bytes |
| コンパイル時間 | 1,066 ms |
| コンパイル使用メモリ | 94,928 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-22 18:09:02 |
| 合計ジャッジ時間 | 8,182 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
#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;
}
}