結果

問題 No.1493 隣接xor
ユーザー the-xinthe-xin
提出日時 2021-07-12 10:23:40
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 635 bytes
コンパイル時間 742 ms
コンパイル使用メモリ 84,184 KB
実行使用メモリ 21,336 KB
最終ジャッジ日時 2023-09-14 20:30:23
合計ジャッジ時間 3,963 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,584 KB
testcase_01 AC 3 ms
7,480 KB
testcase_02 AC 3 ms
7,452 KB
testcase_03 AC 90 ms
21,264 KB
testcase_04 AC 86 ms
21,336 KB
testcase_05 AC 88 ms
21,004 KB
testcase_06 AC 96 ms
20,956 KB
testcase_07 AC 94 ms
21,008 KB
testcase_08 AC 90 ms
21,204 KB
testcase_09 AC 95 ms
20,972 KB
testcase_10 AC 89 ms
21,260 KB
testcase_11 AC 95 ms
21,048 KB
testcase_12 AC 89 ms
20,944 KB
testcase_13 AC 38 ms
12,044 KB
testcase_14 AC 26 ms
11,852 KB
testcase_15 AC 4 ms
7,580 KB
testcase_16 AC 4 ms
7,544 KB
testcase_17 AC 4 ms
7,600 KB
testcase_18 AC 4 ms
7,392 KB
testcase_19 AC 4 ms
7,536 KB
testcase_20 AC 41 ms
16,332 KB
testcase_21 AC 45 ms
16,520 KB
testcase_22 AC 30 ms
12,608 KB
testcase_23 AC 41 ms
16,268 KB
testcase_24 AC 86 ms
21,136 KB
testcase_25 AC 29 ms
12,604 KB
testcase_26 AC 48 ms
17,040 KB
testcase_27 AC 21 ms
11,752 KB
testcase_28 AC 83 ms
21,008 KB
testcase_29 AC 50 ms
17,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<unordered_map>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int n,a[1000500],c[1000500],f[1000500],ans=0;
unordered_map<int,int>last;
const int mod=1e9+7;
int main() {
    ios::sync_with_stdio(0);
    int n,m;
    cin>>n;
    for(int i=1;i<=n;i++){
    	cin>>c[i];
    	a[i]=a[i-1]^c[i];
	}
	ans=0;
    memset(f,0,sizeof(f));
    last[0]=0;
    f[0]=1;
    for(int i=1;i<=n;i++) {
        if(last[a[i]]-1<0)f[i]=(2ll*f[i-1])%mod;
        else f[i]=(2ll*f[i-1]-f[last[a[i]]-1]+mod)%mod;
        last[a[i]]=i;
    }
    ans=(f[n-1]%mod+mod)%mod;
    cout<<ans<<endl;
    return 0;
}
0