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
-
2
1
#ifndef CP_ALGO_STRUCTURES_BITPACK_HPP
3
2
#define CP_ALGO_STRUCTURES_BITPACK_HPP
4
- #include " bit_array.hpp"
3
+ #include " ../structures/ bit_array.hpp"
5
4
#include < cstdint>
6
5
#include < cstddef>
7
6
#include < string>
Original file line number Diff line number Diff line change 2
2
// @brief Matrix Product (Mod 2)
3
3
#define PROBLEM " https://judge.yosupo.jp/problem/matrix_product_mod_2"
4
4
#pragma GCC optimize("Ofast,unroll-loops")
5
- #pragma GCC target("tune=native")
6
5
#include " cp-algo/structures/bitpack.hpp"
7
6
#include < bits/stdc++.h>
8
7
@@ -11,6 +10,19 @@ using cp_algo::structures::bitpack;
11
10
12
11
const int maxn = 1 << 12 ;
13
12
bitpack<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
+ }
14
26
15
27
void solve () {
16
28
int n, m, k;
@@ -24,10 +36,11 @@ void solve() {
24
36
cin >> row;
25
37
b[i] = row;
26
38
}
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)];
31
44
}
32
45
}
33
46
}
You can’t perform that action at this time.
0 commit comments