結果

問題 No.1493 隣接xor
ユーザー auauaauaua
提出日時 2021-04-30 23:18:20
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 193 ms / 2,000 ms
コード長 1,102 bytes
コンパイル時間 1,558 ms
コンパイル使用メモリ 175,260 KB
実行使用メモリ 20,480 KB
最終ジャッジ日時 2024-07-19 03:24:42
合計ジャッジ時間 6,043 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

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