File tree Expand file tree Collapse file tree 2 files changed +19
-7
lines changed
verify/structures/bitpack Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Original file line number Diff line number Diff line change 1-
21#ifndef CP_ALGO_STRUCTURES_BITPACK_HPP
32#define CP_ALGO_STRUCTURES_BITPACK_HPP
4- #include " bit_array.hpp"
3+ #include " ../structures/ bit_array.hpp"
54#include < cstdint>
65#include < cstddef>
76#include < string>
Original file line number Diff line number Diff line change 22// @brief Matrix Product (Mod 2)
33#define PROBLEM " https://judge.yosupo.jp/problem/matrix_product_mod_2"
44#pragma GCC optimize("Ofast,unroll-loops")
5- #pragma GCC target("tune=native")
65#include " cp-algo/structures/bitpack.hpp"
76#include < bits/stdc++.h>
87
@@ -11,6 +10,19 @@ using cp_algo::structures::bitpack;
1110
1211const int maxn = 1 << 12 ;
1312bitpack<maxn> a[maxn], b[maxn], c[maxn];
13+ const int K = 8 ;
14+ bitpack<maxn> precalc[maxn / K][1 << K];
15+
16+ void process_precalc () {
17+ for (int i = 0 ; i < maxn / K; i++) {
18+ for (int j = 0 ; j < K; j++) {
19+ int step = 1 << j;
20+ for (int k = 0 ; k < step; k++) {
21+ precalc[i][k + step] = precalc[i][k] ^ b[K * i + j];
22+ }
23+ }
24+ }
25+ }
1426
1527void solve () {
1628 int n, m, k;
@@ -24,10 +36,11 @@ void solve() {
2436 cin >> row;
2537 b[i] = row;
2638 }
27- for (int i = 0 ; i < n; i++) {
28- for (int j = 0 ; j < m; j++) {
29- if (a[i][j]) {
30- c[i] ^= b[j];
39+ process_precalc ();
40+ for (int j = 0 ; j < m; j += 64 ) {
41+ for (int z = 0 ; z < 64 / K; z++) {
42+ for (int i = 0 ; i < n; i++) {
43+ c[i] ^= precalc[j / K + z][uint8_t (a[i].word (j / 64 ) >> K * z)];
3144 }
3245 }
3346 }
You can’t perform that action at this time.
0 commit comments