結果
| 問題 |
No.1245 ANDORゲーム(calc)
|
| コンテスト | |
| ユーザー |
Haa
|
| 提出日時 | 2020-10-02 21:41:20 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 240 ms / 2,000 ms |
| コード長 | 797 bytes |
| コンパイル時間 | 1,989 ms |
| コンパイル使用メモリ | 173,252 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-16 04:33:38 |
| 合計ジャッジ時間 | 7,533 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(v) v.begin(),v.end()
int main(){
int n, q; cin >> n >> q;
VI a(n); REP(i,n) cin >> a[i];
string s; cin >> s;
VVI p(33,VI(2,0));
int now0, now1;
int b0, b1;
for(int i=0;i<=32;i++){
now0=0; now1=1;
REP(j,n){
b0=now0; b1=now1;
if(s[j]=='0'){
now0&=(a[j]>>i&1);
now1&=(a[j]>>i&1);
}
else{
now0|=(a[j]>>i&1);
now1|=(a[j]>>i&1);
}
p[i][0]+=(now0^b0)*(1ll<<i);
p[i][1]+=(now1^b1)*(1ll<<i);
}
}
ll t; ll ans;
while(q--){
cin >> t;
ans=0;
REP(i,33) ans+=p[i][t>>i&1];
cout << ans << endl;
}
return 0;
}
Haa