結果

問題 No.1493 隣接xor
ユーザー the-xinthe-xin
提出日時 2021-07-12 09:56:59
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 587 bytes
コンパイル時間 671 ms
コンパイル使用メモリ 78,280 KB
実行使用メモリ 14,932 KB
最終ジャッジ日時 2023-09-14 20:29:55
合計ジャッジ時間 3,791 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 106 ms
14,796 KB
testcase_04 AC 105 ms
14,932 KB
testcase_05 AC 102 ms
14,844 KB
testcase_06 AC 102 ms
14,860 KB
testcase_07 AC 103 ms
14,888 KB
testcase_08 AC 104 ms
14,856 KB
testcase_09 AC 98 ms
14,852 KB
testcase_10 AC 102 ms
14,812 KB
testcase_11 AC 110 ms
14,864 KB
testcase_12 AC 108 ms
14,792 KB
testcase_13 AC 38 ms
5,784 KB
testcase_14 AC 26 ms
5,760 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 40 ms
8,860 KB
testcase_21 AC 47 ms
9,536 KB
testcase_22 AC 29 ms
7,256 KB
testcase_23 AC 42 ms
8,916 KB
testcase_24 AC 98 ms
14,928 KB
testcase_25 AC 29 ms
7,192 KB
testcase_26 AC 51 ms
9,792 KB
testcase_27 AC 19 ms
6,032 KB
testcase_28 AC 94 ms
14,656 KB
testcase_29 AC 52 ms
9,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<unordered_map>
using namespace std;
const int N=200005;
const int MOD=1000000007;
int n;
int a[N];
int sum[N];
int f[N];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
        sum[i]=sum[i-1]^a[i];
    unordered_map<int,int>pre;
    f[0]=1;
    for(int i=1;i<=n-1;i++)
    {
        f[i]=f[i-1]*2%MOD;
        if(pre[sum[i]]-1>=0)
        f[i]=(f[i]-f[pre[sum[i]]-1])%MOD;
        f[i]+=MOD;
        f[i]%=MOD;
        pre[sum[i]]=i;
	}
    printf("%d",f[n-1]);
    return 0;
}
0