結果

問題 No.1493 隣接xor
ユーザー the-xinthe-xin
提出日時 2021-07-12 10:24:14
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 617 bytes
コンパイル時間 812 ms
コンパイル使用メモリ 81,096 KB
実行使用メモリ 21,444 KB
最終ジャッジ日時 2023-09-14 20:30:27
合計ジャッジ時間 3,897 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,448 KB
testcase_01 AC 3 ms
7,372 KB
testcase_02 AC 3 ms
7,384 KB
testcase_03 AC 99 ms
21,072 KB
testcase_04 AC 97 ms
21,204 KB
testcase_05 AC 96 ms
21,172 KB
testcase_06 AC 93 ms
21,248 KB
testcase_07 AC 96 ms
21,152 KB
testcase_08 AC 94 ms
20,980 KB
testcase_09 AC 91 ms
21,444 KB
testcase_10 AC 93 ms
21,176 KB
testcase_11 AC 97 ms
20,976 KB
testcase_12 AC 99 ms
20,972 KB
testcase_13 AC 38 ms
11,964 KB
testcase_14 AC 25 ms
11,840 KB
testcase_15 AC 4 ms
7,380 KB
testcase_16 AC 3 ms
7,380 KB
testcase_17 AC 4 ms
7,420 KB
testcase_18 AC 4 ms
7,392 KB
testcase_19 AC 4 ms
7,520 KB
testcase_20 AC 42 ms
16,472 KB
testcase_21 AC 48 ms
16,660 KB
testcase_22 AC 31 ms
12,764 KB
testcase_23 AC 43 ms
16,292 KB
testcase_24 AC 88 ms
21,176 KB
testcase_25 AC 30 ms
12,712 KB
testcase_26 AC 50 ms
16,948 KB
testcase_27 AC 21 ms
11,804 KB
testcase_28 AC 87 ms
21,200 KB
testcase_29 AC 51 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));
    f[0]=1;
    for(int i=1;i<=n;i++) {
        if(!last[a[i]])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