結果

問題 No.1493 隣接xor
ユーザー mortalmortal
提出日時 2022-01-23 12:19:07
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 225 ms / 2,000 ms
コード長 573 bytes
コンパイル時間 2,449 ms
コンパイル使用メモリ 172,380 KB
実行使用メモリ 16,132 KB
最終ジャッジ日時 2023-08-19 16:45:00
合計ジャッジ時間 10,029 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 219 ms
15,860 KB
testcase_04 AC 216 ms
15,876 KB
testcase_05 AC 208 ms
15,828 KB
testcase_06 AC 213 ms
15,880 KB
testcase_07 AC 216 ms
16,132 KB
testcase_08 AC 219 ms
15,944 KB
testcase_09 AC 213 ms
15,860 KB
testcase_10 AC 224 ms
15,872 KB
testcase_11 AC 225 ms
15,868 KB
testcase_12 AC 211 ms
15,828 KB
testcase_13 AC 83 ms
6,544 KB
testcase_14 AC 32 ms
6,452 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 93 ms
9,772 KB
testcase_21 AC 108 ms
10,700 KB
testcase_22 AC 71 ms
8,540 KB
testcase_23 AC 96 ms
9,884 KB
testcase_24 AC 205 ms
15,484 KB
testcase_25 AC 71 ms
8,408 KB
testcase_26 AC 120 ms
11,128 KB
testcase_27 AC 44 ms
6,772 KB
testcase_28 AC 186 ms
14,652 KB
testcase_29 AC 126 ms
11,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define mod 1000000007



int main() {
	int t=1;
	//cin>>t;
	assert(t>=1&&t<=10);
	while(t--){
		int n,i,j;
		cin>>n;
		//assert(n>=1&&n<=100000);
		int a[n];
		int b[n+1];
		b[0]=0;
		for(i=0;i<n;i++){
			cin>>a[i];
			//assert(a[i]>=0&&a[i]<=1000000000);
			b[i+1]=b[i]^a[i];
		}
		map<int,int>m;
		ll dp[n];
		dp[0]=1;
		for(i=1;i<n;i++){
			dp[i]=(dp[i-1]*2)%mod;
			if(m.find(b[i])!=m.end()){
				dp[i]=(dp[i]-dp[m[b[i]]-1]+mod)%mod;

			}
			m[b[i]]=i;

		}
		cout<<dp[n-1]%mod<<"\n";



	}
	
}
0