結果

問題 No.1493 隣接xor
ユーザー the-xinthe-xin
提出日時 2021-07-12 09:48:57
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 583 bytes
コンパイル時間 1,011 ms
コンパイル使用メモリ 76,980 KB
実行使用メモリ 15,028 KB
最終ジャッジ日時 2023-09-14 20:29:37
合計ジャッジ時間 3,886 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 94 ms
14,860 KB
testcase_04 AC 98 ms
14,884 KB
testcase_05 AC 101 ms
15,020 KB
testcase_06 AC 97 ms
14,904 KB
testcase_07 AC 95 ms
14,856 KB
testcase_08 AC 96 ms
14,852 KB
testcase_09 AC 97 ms
14,964 KB
testcase_10 AC 99 ms
14,840 KB
testcase_11 AC 95 ms
15,028 KB
testcase_12 AC 101 ms
14,904 KB
testcase_13 AC 38 ms
5,740 KB
testcase_14 AC 26 ms
5,820 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 39 ms
8,876 KB
testcase_21 AC 46 ms
9,492 KB
testcase_22 AC 29 ms
7,324 KB
testcase_23 AC 41 ms
9,020 KB
testcase_24 AC 94 ms
14,864 KB
testcase_25 AC 28 ms
7,272 KB
testcase_26 AC 50 ms
9,988 KB
testcase_27 AC 19 ms
6,032 KB
testcase_28 AC 87 ms
14,664 KB
testcase_29 AC 51 ms
9,876 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[1]=1;
    for(int i=2;i<=n;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]);
    return 0;
}
0