結果

問題 No.1245 ANDORゲーム(calc)
ユーザー tempura_pptempura_pp
提出日時 2020-08-05 12:33:54
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 212 ms / 2,000 ms
コード長 752 bytes
コンパイル時間 3,117 ms
コンパイル使用メモリ 200,904 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-14 10:59:54
合計ジャッジ時間 11,554 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,352 KB
testcase_07 AC 6 ms
4,348 KB
testcase_08 AC 3 ms
4,356 KB
testcase_09 AC 6 ms
4,352 KB
testcase_10 AC 7 ms
4,372 KB
testcase_11 AC 212 ms
4,348 KB
testcase_12 AC 209 ms
4,348 KB
testcase_13 AC 209 ms
4,352 KB
testcase_14 AC 211 ms
4,352 KB
testcase_15 AC 211 ms
4,356 KB
testcase_16 AC 211 ms
4,348 KB
testcase_17 AC 198 ms
4,348 KB
testcase_18 AC 194 ms
4,352 KB
testcase_19 AC 189 ms
4,356 KB
testcase_20 AC 199 ms
4,352 KB
testcase_21 AC 196 ms
4,352 KB
testcase_22 AC 192 ms
4,348 KB
testcase_23 AC 204 ms
4,352 KB
testcase_24 AC 204 ms
4,352 KB
testcase_25 AC 164 ms
4,348 KB
testcase_26 AC 165 ms
4,372 KB
testcase_27 AC 177 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0