結果

問題 No.1493 隣接xor
ユーザー auauaauaua
提出日時 2021-04-30 23:18:20
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 247 ms / 2,000 ms
コード長 1,102 bytes
コンパイル時間 1,850 ms
コンパイル使用メモリ 173,812 KB
実行使用メモリ 20,448 KB
最終ジャッジ日時 2023-09-26 08:18:02
合計ジャッジ時間 8,192 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 236 ms
20,328 KB
testcase_04 AC 235 ms
20,172 KB
testcase_05 AC 239 ms
20,108 KB
testcase_06 AC 234 ms
20,304 KB
testcase_07 AC 238 ms
20,120 KB
testcase_08 AC 229 ms
20,448 KB
testcase_09 AC 234 ms
20,104 KB
testcase_10 AC 236 ms
20,108 KB
testcase_11 AC 236 ms
20,440 KB
testcase_12 AC 247 ms
20,220 KB
testcase_13 AC 88 ms
7,872 KB
testcase_14 AC 35 ms
7,752 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 109 ms
12,032 KB
testcase_21 AC 124 ms
13,044 KB
testcase_22 AC 77 ms
10,268 KB
testcase_23 AC 106 ms
12,296 KB
testcase_24 AC 229 ms
19,332 KB
testcase_25 AC 82 ms
10,000 KB
testcase_26 AC 135 ms
13,932 KB
testcase_27 AC 47 ms
7,564 KB
testcase_28 AC 211 ms
18,544 KB
testcase_29 AC 140 ms
14,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
#define double long double
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
//typedef long double ld;
typedef complex<double> Complex;
const ll INF=1e9+7;
const ll MOD=INF;
const ll inf=INF*INF;
const ll mod=MOD;
const ll MAX=100010;



signed main(){
    ll n;cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    vector<ll>dp(n);
    vector<ll>b(n);
    REP(i,1,n){
        b[i]=a[i-1]^b[i-1];

    }
    map<ll,ll>la;
    dp[0]=1;
    REP(i,1,n){
        if(la.find(b[i])==la.end()){
            dp[i]=dp[i-1];
        }else{
            dp[i]=dp[i-1]-dp[la[b[i]]-1];
        }
        dp[i]=(dp[i]+dp[i-1])%mod;
        la[b[i]]=i;
    }
    ll ans=dp[n-1];
    if(ans<0)ans+=mod;
    cout<<ans<<endl;
}
0