結果

問題 No.1863 Xor Sum 2...?
ユーザー otoshigootoshigo
提出日時 2022-03-04 22:18:55
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 1,643 bytes
コンパイル時間 1,980 ms
コンパイル使用メモリ 204,012 KB
実行使用メモリ 20,372 KB
最終ジャッジ日時 2023-09-26 01:23:00
合計ジャッジ時間 4,510 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 13 ms
5,892 KB
testcase_06 AC 7 ms
4,436 KB
testcase_07 AC 23 ms
8,328 KB
testcase_08 AC 23 ms
8,392 KB
testcase_09 AC 59 ms
17,104 KB
testcase_10 AC 54 ms
15,924 KB
testcase_11 AC 32 ms
10,428 KB
testcase_12 AC 22 ms
8,052 KB
testcase_13 AC 45 ms
13,668 KB
testcase_14 AC 56 ms
15,984 KB
testcase_15 AC 44 ms
13,352 KB
testcase_16 AC 45 ms
13,944 KB
testcase_17 AC 25 ms
8,848 KB
testcase_18 AC 11 ms
5,344 KB
testcase_19 AC 22 ms
7,852 KB
testcase_20 AC 35 ms
11,240 KB
testcase_21 AC 50 ms
14,928 KB
testcase_22 AC 19 ms
7,260 KB
testcase_23 AC 65 ms
18,424 KB
testcase_24 AC 69 ms
19,352 KB
testcase_25 AC 72 ms
20,216 KB
testcase_26 AC 73 ms
20,272 KB
testcase_27 AC 72 ms
20,276 KB
testcase_28 AC 73 ms
20,156 KB
testcase_29 AC 71 ms
20,208 KB
testcase_30 AC 72 ms
20,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,a,b) for (int i = a; i < b; i++)
#define rrep2(i,a,b) for (int i = a-1; i >= b; i--)
#define rep3(i,a,b,c) for (int i = a; i < b; i+=c)
#define rrep3(i,a,b,c) for (int i = a-1; i >= b; i-=c)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}
template<class T> T pow(T x, ll y){if (y == 0) return 1;T p = pow(x,y/2);if (y%2 == 0) return p*p;else return p*p*x;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    vector<int> A(n), B(n+1);
    rep(i,n) cin >> A[i];
    rep(i,n) cin >> B[i+1];
    vector<vector<int>> S(n+1,vector<int>(31));
    rep(i,n){
        rep(j,31) S[i+1][j] = S[i][j];
        int a = A[i];
        int j = 0;
        while (a > 0){
            if (a&1) S[i+1][j]++;
            a>>=1;
            j++;
        }
        B[i+1] ^= B[i];
    }
    int ans = 0;
    rep2(r,1,n+1){
        int l = max(r-30,0);
        while (l != r){
            if (B[l] != B[r]){
                l++;
                continue;
            }
            bool flag = true;
            rep(i,31){
                if (S[r][i]-S[l][i] > 1){
                    flag = false;
                    break;
                }
            }
            if (flag) ans++;
            l++;
        }
    }
    cout << ans << endl;
}
0