結果
| 問題 |
No.1245 ANDORゲーム(calc)
|
| コンテスト | |
| ユーザー |
tempura_pp
|
| 提出日時 | 2020-08-05 12:33:54 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 243 ms / 2,000 ms |
| コード長 | 752 bytes |
| コンパイル時間 | 2,050 ms |
| コンパイル使用メモリ | 196,732 KB |
| 最終ジャッジ日時 | 2025-01-12 14:43:45 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
ll res[2][30];
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n,q;
cin>>n>>q;
vector<int> a(n);
rep(i,n)cin>>a[i];
string s;cin>>s;
rep(i,2)rep(j,30){
int cur = i;
rep(k,n){
int nxt = cur;
if(s[k]=='0')nxt &= (a[k]>>j)&1;
else nxt |= (a[k]>>j)&1;
if(nxt != cur) res[i][j]++;
cur = nxt;
}
}
rep(i,q){
int t;
cin>>t;
ll ans = 0;
rep(j,30)ans += (1ll<<j) * res[(t>>j)&1][j];
cout << ans << endl;
}
return 0;
}
tempura_pp