結果

問題 No.1493 隣接xor
ユーザー keijakkeijak
提出日時 2021-05-01 04:53:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,113 bytes
コンパイル時間 2,316 ms
コンパイル使用メモリ 212,104 KB
実行使用メモリ 15,600 KB
最終ジャッジ日時 2023-09-26 13:09:48
合計ジャッジ時間 6,698 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 149 ms
15,464 KB
testcase_04 AC 146 ms
15,496 KB
testcase_05 AC 161 ms
15,436 KB
testcase_06 AC 151 ms
15,600 KB
testcase_07 AC 148 ms
15,420 KB
testcase_08 AC 152 ms
15,484 KB
testcase_09 AC 156 ms
15,496 KB
testcase_10 AC 168 ms
15,412 KB
testcase_11 AC 164 ms
15,420 KB
testcase_12 AC 157 ms
15,432 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 67 ms
9,364 KB
testcase_21 AC 78 ms
10,340 KB
testcase_22 AC 50 ms
8,248 KB
testcase_23 AC 68 ms
9,684 KB
testcase_24 AC 150 ms
15,224 KB
testcase_25 AC 48 ms
8,136 KB
testcase_26 AC 83 ms
10,996 KB
testcase_27 AC 30 ms
6,240 KB
testcase_28 AC 148 ms
14,532 KB
testcase_29 AC 96 ms
11,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP_(i, a_, b_, a, b, ...) \
  for (int i = (a), END_##i = (b); i < END_##i; ++i)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define ALL(x) std::begin(x), std::end(x)
using u32 = unsigned;

#include <atcoder/modint>
using Mint = atcoder::modint1000000007;
std::ostream &operator<<(std::ostream &os, const Mint &m) {
  return os << m.val();
}
template <typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &a) {
  for (auto &x : a) is >> x;
  return is;
}
using namespace std;

Mint solve() {
  int n;
  cin >> n;
  vector<u32> a(n), b(n + 1);
  cin >> a;
  REP(i, n) b[i + 1] = b[i] ^ a[i];

  vector dp(n + 1, Mint(0)), dpcum(n + 2, Mint(0));
  dp[0] = 1;
  dpcum[1] = 1;
  map<u32, int> pre;
  pre[0] = 0;
  REP(i, n) {
    auto it = pre.find(b[i + 1]);
    int j = (it == pre.end()) ? 0 : it->second;
    dp[i + 1] = dpcum[i + 1] - dpcum[j];
    dpcum[i + 2] = dpcum[i + 1] + dp[i + 1];
    pre[b[i + 1]] = i + 1;
  }
  return dp[n];
}

int main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  cout << solve() << "\n";
}
0