結果

問題 No.1493 隣接xor
ユーザー chocoruskchocorusk
提出日時 2021-04-30 21:55:51
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 232 ms / 2,000 ms
コード長 1,519 bytes
コンパイル時間 3,429 ms
コンパイル使用メモリ 197,540 KB
実行使用メモリ 14,952 KB
最終ジャッジ日時 2023-09-26 05:59:13
合計ジャッジ時間 8,534 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 213 ms
14,656 KB
testcase_04 AC 217 ms
14,704 KB
testcase_05 AC 220 ms
14,800 KB
testcase_06 AC 213 ms
14,704 KB
testcase_07 AC 213 ms
14,708 KB
testcase_08 AC 212 ms
14,952 KB
testcase_09 AC 224 ms
14,708 KB
testcase_10 AC 223 ms
14,760 KB
testcase_11 AC 226 ms
14,700 KB
testcase_12 AC 232 ms
14,744 KB
testcase_13 AC 93 ms
5,560 KB
testcase_14 AC 39 ms
5,500 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 98 ms
9,108 KB
testcase_21 AC 114 ms
10,036 KB
testcase_22 AC 76 ms
7,908 KB
testcase_23 AC 98 ms
9,140 KB
testcase_24 AC 226 ms
14,368 KB
testcase_25 AC 75 ms
7,892 KB
testcase_26 AC 129 ms
10,432 KB
testcase_27 AC 46 ms
6,248 KB
testcase_28 AC 203 ms
13,896 KB
testcase_29 AC 128 ms
10,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
using mint=modint1000000007;
template<typename T>
struct BIT{
    vector<T> bit;
    int size;
    BIT(int n):size(n), bit(n+1, 0){}
    T sum(int i){ //[0, i)
        T s=0;
        while(i>0){
            s+=bit[i];
            i-=(i&(-i));
        }
        return s;
    }
    T sum(int l, int r){ //[l, r)
        return sum(r)-sum(l);
    }
    void add(int i, T x){
        i++;
        while(i<=size){
            bit[i]+=x;
            i+=(i&(-i));
        }
    }
};
int main()
{
    int n; cin>>n;
    int a[200020];
    int s[200020]; s[0]=0;
    for(int i=0; i<n; i++){
        cin>>a[i];
        s[i+1]=(s[i]^a[i]);
    }
    map<int, int> mp;
    mp[0]=0;
    mint ans=1;
    BIT<mint> bit(n+1);
    bit.add(0, 1);
    for(int i=1; i<n; i++){
        int l=mp[s[i]];
        mp[s[i]]=i;
        mint t=bit.sum(l, i);
        ans+=t;
        bit.add(i, t);
    }
    cout<<ans.val()<<endl;
    return 0;
}
0