結果

問題 No.1493 隣接xor
ユーザー the-xinthe-xin
提出日時 2021-07-13 12:17:25
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 684 bytes
コンパイル時間 1,618 ms
コンパイル使用メモリ 172,808 KB
実行使用メモリ 14,924 KB
最終ジャッジ日時 2023-09-15 08:51:36
合計ジャッジ時間 6,706 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 WA -
testcase_02 RE -
testcase_03 AC 186 ms
14,924 KB
testcase_04 AC 191 ms
14,584 KB
testcase_05 AC 186 ms
14,828 KB
testcase_06 AC 189 ms
14,640 KB
testcase_07 AC 186 ms
14,632 KB
testcase_08 AC 186 ms
14,596 KB
testcase_09 AC 190 ms
14,616 KB
testcase_10 AC 191 ms
14,796 KB
testcase_11 AC 182 ms
14,664 KB
testcase_12 AC 189 ms
14,668 KB
testcase_13 AC 84 ms
5,340 KB
testcase_14 AC 32 ms
5,388 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,500 KB
testcase_20 AC 87 ms
9,140 KB
testcase_21 AC 99 ms
9,876 KB
testcase_22 AC 68 ms
7,872 KB
testcase_23 AC 88 ms
9,116 KB
testcase_24 AC 186 ms
14,324 KB
testcase_25 AC 65 ms
7,932 KB
testcase_26 AC 107 ms
10,400 KB
testcase_27 AC 42 ms
5,960 KB
testcase_28 AC 168 ms
13,748 KB
testcase_29 AC 116 ms
10,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::vector;
using ll = long long;
const ll mod = 1e9+7;
#define rep(i,j,k) for(int i=int(j); i<int(k); i++)
#define REP(i,j,k) for(int i=int(j); i<=int(k); i++)

int main(){
    int N; cin >> N;
    vector<int> A(N), B(N+1);
    std::map<int,int> mem;
    rep(i,0,N){
        cin >> A[i];
        B[i+1] = A[i]^B[i];
    }
    vector<int> dp(N);
    REP(i,1,N){
    	if(i==1)dp[1]=1;
    	else{
    		dp[i] = dp[i-1]*2%mod;
        if(mem.count(B[i])){
            dp[i] -= dp[mem[B[i]]-1];
            if(dp[i] < 0) dp[i] += mod;
        	}
		}
        mem[B[i]] = i;
    }
    cout << dp[N] << endl;
}
0