結果

問題 No.1493 隣接xor
ユーザー 沙耶花沙耶花
提出日時 2021-04-30 22:01:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 445 ms / 2,000 ms
コード長 832 bytes
コンパイル時間 4,890 ms
コンパイル使用メモリ 268,548 KB
実行使用メモリ 28,980 KB
最終ジャッジ日時 2023-09-26 06:05:51
合計ジャッジ時間 12,993 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 440 ms
28,976 KB
testcase_04 AC 428 ms
28,980 KB
testcase_05 AC 430 ms
28,388 KB
testcase_06 AC 444 ms
28,432 KB
testcase_07 AC 430 ms
28,436 KB
testcase_08 AC 440 ms
28,388 KB
testcase_09 AC 433 ms
28,740 KB
testcase_10 AC 434 ms
28,696 KB
testcase_11 AC 445 ms
28,428 KB
testcase_12 AC 442 ms
28,432 KB
testcase_13 AC 107 ms
7,648 KB
testcase_14 AC 57 ms
7,644 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 195 ms
16,296 KB
testcase_21 AC 229 ms
17,820 KB
testcase_22 AC 144 ms
13,740 KB
testcase_23 AC 218 ms
16,232 KB
testcase_24 AC 426 ms
27,640 KB
testcase_25 AC 143 ms
13,344 KB
testcase_26 AC 248 ms
18,668 KB
testcase_27 AC 81 ms
9,640 KB
testcase_28 AC 405 ms
26,356 KB
testcase_29 AC 257 ms
19,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint1000000007;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000

mint op(mint a,mint b){
	return a+b;
}

mint e(){
	return 0;
}

int main(){
	
	int N;
	cin>>N;
	
	vector<int> A(N);
	rep(i,N){
		cin>>A[i];
	}
	
	rep(i,N-1){
		A[i+1] ^= A[i];
	}
	
	map<int,vector<int>> mp;
	
	rep(i,N){
		mp[A[i]].push_back(i);
	}
	
	segtree<mint,op,e> seg(N);
	
	rep(i,N){
		int d = distance(mp[A[i]].begin(),lower_bound(mp[A[i]].begin(),mp[A[i]].end(),i));
		if(d==0){
			seg.set(i,seg.all_prod()+1);
		}
		else{
			int ind = mp[A[i]][d-1];
			seg.set(i,seg.prod(ind,i+1));
		}
	}
	
	mint ans = 0;
	
	rep(i,N){
		if(A[i]==A.back())ans += seg.get(i);
	}
	
	cout<<ans.val()<<endl;
	
	
    return 0;
}
0