結果

問題 No.1142 XOR と XOR
ユーザー ooaiu
提出日時 2025-07-02 09:10:37
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 823 bytes
コンパイル時間 3,319 ms
コンパイル使用メモリ 278,920 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-07-02 09:10:54
合計ジャッジ時間 16,714 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 3 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const int md = 1e9 + 7;
const int K = 10;
vector<int> solve(const vector<int>& a) {
	const int n = a.size();
	vector<int> S(n + 1);
	for(int i = 0; i < n; i++) S[i + 1] = S[i] ^ a[i];
	vector<int> ans(1<<K);
	vector<long> cnt(1<<K);
	cnt[0] = 1;
	for(int j = 1; j <= n; j++) {
		for(int x = 0; x < (1<<K); x++) {
			ans[x] += cnt[x ^ S[j]];
			ans[x] %= md;
		}
		cnt[S[j]] += 1;
	}
	return ans;
}
int main() {
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int N, M, L;
	cin >> N >> M >> L;
	vector<int> A(N), B(M);
	for(int i = 0; i < N; i++) cin >> A[i];
	for(int i = 0; i < M; i++) cin >> B[i];
	auto SA = solve(A);
	auto SB = solve(B);
	long ans = 0;
	for(int i = 0; i < (1<<K); i++) {
		ans += SA[i] * SB[L ^ i];
		ans %= md;
	}
	cout << ans << "\n";
}
0