結果

問題 No.1493 隣接xor
ユーザー 00 Sakuda00 Sakuda
提出日時 2024-04-03 00:41:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 243 ms / 2,000 ms
コード長 600 bytes
コンパイル時間 2,522 ms
コンパイル使用メモリ 213,900 KB
実行使用メモリ 18,944 KB
最終ジャッジ日時 2024-04-03 00:41:42
合計ジャッジ時間 9,591 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 223 ms
18,944 KB
testcase_04 AC 218 ms
18,944 KB
testcase_05 AC 243 ms
18,944 KB
testcase_06 AC 209 ms
18,944 KB
testcase_07 AC 214 ms
18,944 KB
testcase_08 AC 217 ms
18,944 KB
testcase_09 AC 231 ms
18,944 KB
testcase_10 AC 218 ms
18,944 KB
testcase_11 AC 243 ms
18,944 KB
testcase_12 AC 212 ms
18,944 KB
testcase_13 AC 91 ms
6,676 KB
testcase_14 AC 35 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 96 ms
11,392 KB
testcase_21 AC 113 ms
12,544 KB
testcase_22 AC 74 ms
9,728 KB
testcase_23 AC 97 ms
11,520 KB
testcase_24 AC 213 ms
18,304 KB
testcase_25 AC 72 ms
9,600 KB
testcase_26 AC 154 ms
13,056 KB
testcase_27 AC 46 ms
7,424 KB
testcase_28 AC 189 ms
17,408 KB
testcase_29 AC 130 ms
13,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using ll = long long;
using namespace atcoder;
using mint = modint;
int main() {
	mint::set_mod((ll)1e9 + 7);
	int N;cin >> N;
	vector<ll> S(N + 1, 0);
	for (int i = 1;i <= N;i++) {
		ll a;cin >> a;
		S[i] = S[i - 1] ^ a;
	}
	vector<mint> dp(N + 1, 0);
	dp[0] = 1;
	map<ll, int> pos;
	vector<mint> sdp(N + 1, 0);
	sdp[0] = 1;
	for (int i = 1;i <= N - 1;i++) {
		dp[i] = sdp[i - 1] - (pos.find(S[i]) == pos.end() ? 0 : sdp[pos[S[i]] - 1]);
		pos[S[i]] = i;
		sdp[i] = sdp[i - 1] + dp[i];
	}
	cout << sdp[N - 1].val() << endl;

}
0