結果

問題 No.1493 隣接xor
ユーザー SSRSSSRS
提出日時 2021-04-30 21:42:51
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 681 bytes
コンパイル時間 1,623 ms
コンパイル使用メモリ 176,788 KB
実行使用メモリ 17,280 KB
最終ジャッジ日時 2024-07-19 00:58:25
合計ジャッジ時間 5,848 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<int> X(N + 1);
  X[0] = 0;
  for (int i = 0; i < N; i++){
    X[i + 1] = X[i] ^ A[i];
  }
  bool ok = false;  
  for (int i = 0; i < N; i++){
    if (A[i] != 0){
      ok = true;
    }
  }
  if (!ok){
    cout << N << endl;
  } else {
    map<int, long long> mp;
    mp[0] = 1;
    long long sum = 1;
    for (int i = 1; i < N; i++){
      long long next = sum;
      sum += MOD - mp[X[i]];
      sum += next;
      sum %= MOD;
      mp[X[i]] = next;
    }
    cout << sum << endl;
  }
}
0