結果

問題 No.1493 隣接xor
ユーザー SSRSSSRS
提出日時 2021-04-30 21:39:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 694 bytes
コンパイル時間 1,646 ms
コンパイル使用メモリ 174,412 KB
実行使用メモリ 17,312 KB
最終ジャッジ日時 2023-09-26 05:31:17
合計ジャッジ時間 6,974 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 250 ms
17,164 KB
testcase_04 AC 245 ms
16,988 KB
testcase_05 AC 237 ms
16,980 KB
testcase_06 AC 239 ms
17,028 KB
testcase_07 AC 250 ms
17,312 KB
testcase_08 AC 230 ms
17,096 KB
testcase_09 AC 242 ms
16,996 KB
testcase_10 AC 235 ms
17,092 KB
testcase_11 AC 229 ms
17,036 KB
testcase_12 AC 235 ms
17,080 KB
testcase_13 WA -
testcase_14 AC 29 ms
4,944 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 110 ms
10,292 KB
testcase_21 AC 123 ms
11,260 KB
testcase_22 AC 83 ms
8,848 KB
testcase_23 AC 110 ms
10,472 KB
testcase_24 AC 234 ms
16,508 KB
testcase_25 AC 82 ms
8,544 KB
testcase_26 AC 143 ms
11,816 KB
testcase_27 AC 49 ms
6,864 KB
testcase_28 AC 210 ms
15,756 KB
testcase_29 AC 139 ms
12,008 KB
権限があれば一括ダウンロードができます

ソースコード

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 tmp = sum + MOD - mp[X[i]];
      tmp %= MOD;
      mp[X[i]] = sum;
      sum = tmp + mp[X[i]];
      sum %= MOD;
    }
    cout << sum << endl;
  }
}
0