結果
| 問題 |
No.1245 ANDORゲーム(calc)
|
| コンテスト | |
| ユーザー |
startcpp
|
| 提出日時 | 2020-10-02 22:53:18 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 256 ms / 2,000 ms |
| コード長 | 735 bytes |
| コンパイル時間 | 513 ms |
| コンパイル使用メモリ | 67,448 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-17 22:53:41 |
| 合計ジャッジ時間 | 6,773 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
//実家
#include <iostream>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;
int n, q;
int a[100000];
string s;
int t[100000];
int memo[30][2];
signed main() {
int i, j, k;
cin >> n >> q;
rep(i, n) cin >> a[i];
cin >> s;
rep(i, q) cin >> t[i];
rep(i, 30) {
rep(j, 2) {
int x = j;
int rng = 0;
rep(k, n) {
int val = (a[k] >> i) % 2;
int nx;
if (s[k] == '0') {
nx = (x & val);
}
else {
nx = (x | val);
}
rng += abs(nx - x);
x = nx;
}
memo[i][j] = rng;
}
}
rep(i, q) {
int ans = 0;
rep(j, 30) {
ans += (memo[j][(t[i] >> j) % 2] << j);
}
cout << ans << endl;
}
return 0;
}
startcpp