結果

問題 No.1493 隣接xor
ユーザー snow39snow39
提出日時 2021-05-01 10:44:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,277 bytes
コンパイル時間 1,297 ms
コンパイル使用メモリ 122,376 KB
実行使用メモリ 47,040 KB
最終ジャッジ日時 2023-09-27 00:09:15
合計ジャッジ時間 11,554 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 576 ms
46,856 KB
testcase_06 AC 584 ms
46,856 KB
testcase_07 WA -
testcase_08 AC 563 ms
46,780 KB
testcase_09 AC 556 ms
46,744 KB
testcase_10 AC 562 ms
46,728 KB
testcase_11 AC 558 ms
46,864 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 236 ms
25,680 KB
testcase_21 AC 286 ms
28,716 KB
testcase_22 AC 176 ms
21,044 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 96 ms
14,384 KB
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

void add(ll &a,ll b){
  a=(a+b)%MOD;
}

void mul(ll &a,ll b){
  a%=MOD;b%=MOD;
  a=a*b%MOD;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N;
  cin>>N;
  vector<ll> A(N);
  rep(i,N) cin>>A[i];

  vector<ll> B(N);
  B[0]=A[0];
  rep(i,N-1) B[i+1]=B[i]^A[i+1];

  vector<ll> v=B;
  sort(all(v));
  v.erase(unique(all(v)),v.end());
  int V=v.size();
  map<ll,int> mp;
  rep(i,V) mp[v[i]]=i;

  vector<vector<int>> idxs(V);
  rep(i,N) idxs[mp[B[i]]].push_back(i);

  vector<ll> dp(N+1,0);
  dp[0]=1;
  vector<ll> sum(N+2,0);
  sum[1]=1;
  map<ll,int> last;
  rep(i,N) last[B[i]]=-1;
  for(int i=0;i<N;i++){
    int lt=last[B[i]];
    add(dp[i+1],sum[i+1]-sum[lt+1]);
    last[B[i]]=i;
    sum[i+2]=sum[i+1];
    add(sum[i+2],dp[i+1]);
  }

  cout<<dp[N]<<endl;

  return 0;
}
0