Skip to content

Commit 03628bb

Browse files
authored
[auto-verifier] docs commit d4836fa
1 parent 7001e45 commit 03628bb

16 files changed

+148
-431
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ Except such snippets, the programs written by the owner of the repo is under the
3636

3737
## Formatting
3838

39-
`clang-format-16` is used to lint `.cpp` / `.hpp` files. Default configuration file is `.clang-format`. See [formatter.yml](.github/workflows/formatter.yml) for detail.
39+
`clang-format-19` is used to lint `.cpp` / `.hpp` files. Default configuration file is `.clang-format`. See [formatter.yml](.github/workflows/formatter.yml) for detail.

convolution/fft_double.hpp.md

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@ data:
1414
- http://kirika-comp.hatenablog.com/entry/2018/03/12/210446
1515
- https://atcoder.jp/contests/atc001/submissions/9243440
1616
bundledCode: "#line 2 \"convolution/fft_double.hpp\"\n#include <complex>\n#include\
17-
\ <utility>\n#include <vector>\n\n// CUT begin\n// Convolution by FFT (Fast Fourier\
18-
\ Transform)\n// Algorithm based on http://kirika-comp.hatenablog.com/entry/2018/03/12/210446\n\
17+
\ <utility>\n#include <vector>\n\n// Convolution by FFT (Fast Fourier Transform)\n\
18+
// Algorithm based on http://kirika-comp.hatenablog.com/entry/2018/03/12/210446\n\
1919
// Verified: ATC001C (168 ms) https://atcoder.jp/contests/atc001/submissions/9243440\n\
2020
using cmplx = std::complex<double>;\nvoid fft(int N, std::vector<cmplx> &a, double\
2121
\ dir) {\n int i = 0;\n for (int j = 1; j < N - 1; j++) {\n for (int\
22-
\ k = N >> 1; k > (i ^= k); k >>= 1)\n ;\n if (j < i) std::swap(a[i],\
23-
\ a[j]);\n }\n\n std::vector<cmplx> zeta_pow(N);\n for (int i = 0; i\
24-
\ < N; i++) {\n double theta = M_PI / N * i * dir;\n zeta_pow[i]\
25-
\ = {cos(theta), sin(theta)};\n }\n\n for (int m = 1; m < N; m *= 2) {\n\
26-
\ for (int y = 0; y < m; y++) {\n cmplx fac = zeta_pow[N / m\
27-
\ * y];\n for (int x = 0; x < N; x += 2 * m) {\n int\
28-
\ u = x + y;\n int v = x + y + m;\n cmplx s = a[u]\
29-
\ + fac * a[v];\n cmplx t = a[u] - fac * a[v];\n \
30-
\ a[u] = s;\n a[v] = t;\n }\n }\n }\n}\n\
31-
template <typename T>\nstd::vector<cmplx> conv_cmplx(const std::vector<T> &a,\
32-
\ const std::vector<T> &b) {\n int N = 1;\n while (N < (int)a.size() + (int)b.size())\
33-
\ N *= 2;\n std::vector<cmplx> a_(N), b_(N);\n for (int i = 0; i < (int)a.size();\
22+
\ k = N >> 1; k > (i ^= k); k >>= 1) {}\n if (j < i) std::swap(a[i], a[j]);\n\
23+
\ }\n\n std::vector<cmplx> zeta_pow(N);\n for (int i = 0; i < N; i++)\
24+
\ {\n double theta = M_PI / N * i * dir;\n zeta_pow[i] = {cos(theta),\
25+
\ sin(theta)};\n }\n\n for (int m = 1; m < N; m *= 2) {\n for (int\
26+
\ y = 0; y < m; y++) {\n cmplx fac = zeta_pow[N / m * y];\n \
27+
\ for (int x = 0; x < N; x += 2 * m) {\n int u = x + y;\n \
28+
\ int v = x + y + m;\n cmplx s = a[u] + fac * a[v];\n\
29+
\ cmplx t = a[u] - fac * a[v];\n a[u] = s;\n \
30+
\ a[v] = t;\n }\n }\n }\n}\ntemplate <typename\
31+
\ T>\nstd::vector<cmplx> conv_cmplx(const std::vector<T> &a, const std::vector<T>\
32+
\ &b) {\n int N = 1;\n while (N < (int)a.size() + (int)b.size()) N *= 2;\n\
33+
\ std::vector<cmplx> a_(N), b_(N);\n for (int i = 0; i < (int)a.size();\
3434
\ i++) a_[i] = a[i];\n for (int i = 0; i < (int)b.size(); i++) b_[i] = b[i];\n\
3535
\ fft(N, a_, 1);\n fft(N, b_, 1);\n for (int i = 0; i < N; i++) a_[i]\
3636
\ *= b_[i];\n fft(N, a_, -1);\n for (int i = 0; i < N; i++) a_[i] /= N;\n\
@@ -41,23 +41,22 @@ data:
4141
\ for (int i = 0; i < (int)ans.size(); i++) ret[i] = floor(ans[i].real() + 0.5);\n\
4242
\ ret.resize(a.size() + b.size() - 1);\n return ret;\n}\n"
4343
code: "#pragma once\n#include <complex>\n#include <utility>\n#include <vector>\n\
44-
\n// CUT begin\n// Convolution by FFT (Fast Fourier Transform)\n// Algorithm based\
45-
\ on http://kirika-comp.hatenablog.com/entry/2018/03/12/210446\n// Verified: ATC001C\
46-
\ (168 ms) https://atcoder.jp/contests/atc001/submissions/9243440\nusing cmplx\
47-
\ = std::complex<double>;\nvoid fft(int N, std::vector<cmplx> &a, double dir)\
48-
\ {\n int i = 0;\n for (int j = 1; j < N - 1; j++) {\n for (int k\
49-
\ = N >> 1; k > (i ^= k); k >>= 1)\n ;\n if (j < i) std::swap(a[i],\
50-
\ a[j]);\n }\n\n std::vector<cmplx> zeta_pow(N);\n for (int i = 0; i\
51-
\ < N; i++) {\n double theta = M_PI / N * i * dir;\n zeta_pow[i]\
52-
\ = {cos(theta), sin(theta)};\n }\n\n for (int m = 1; m < N; m *= 2) {\n\
53-
\ for (int y = 0; y < m; y++) {\n cmplx fac = zeta_pow[N / m\
54-
\ * y];\n for (int x = 0; x < N; x += 2 * m) {\n int\
55-
\ u = x + y;\n int v = x + y + m;\n cmplx s = a[u]\
56-
\ + fac * a[v];\n cmplx t = a[u] - fac * a[v];\n \
57-
\ a[u] = s;\n a[v] = t;\n }\n }\n }\n}\n\
58-
template <typename T>\nstd::vector<cmplx> conv_cmplx(const std::vector<T> &a,\
59-
\ const std::vector<T> &b) {\n int N = 1;\n while (N < (int)a.size() + (int)b.size())\
60-
\ N *= 2;\n std::vector<cmplx> a_(N), b_(N);\n for (int i = 0; i < (int)a.size();\
44+
\n// Convolution by FFT (Fast Fourier Transform)\n// Algorithm based on http://kirika-comp.hatenablog.com/entry/2018/03/12/210446\n\
45+
// Verified: ATC001C (168 ms) https://atcoder.jp/contests/atc001/submissions/9243440\n\
46+
using cmplx = std::complex<double>;\nvoid fft(int N, std::vector<cmplx> &a, double\
47+
\ dir) {\n int i = 0;\n for (int j = 1; j < N - 1; j++) {\n for (int\
48+
\ k = N >> 1; k > (i ^= k); k >>= 1) {}\n if (j < i) std::swap(a[i], a[j]);\n\
49+
\ }\n\n std::vector<cmplx> zeta_pow(N);\n for (int i = 0; i < N; i++)\
50+
\ {\n double theta = M_PI / N * i * dir;\n zeta_pow[i] = {cos(theta),\
51+
\ sin(theta)};\n }\n\n for (int m = 1; m < N; m *= 2) {\n for (int\
52+
\ y = 0; y < m; y++) {\n cmplx fac = zeta_pow[N / m * y];\n \
53+
\ for (int x = 0; x < N; x += 2 * m) {\n int u = x + y;\n \
54+
\ int v = x + y + m;\n cmplx s = a[u] + fac * a[v];\n\
55+
\ cmplx t = a[u] - fac * a[v];\n a[u] = s;\n \
56+
\ a[v] = t;\n }\n }\n }\n}\ntemplate <typename\
57+
\ T>\nstd::vector<cmplx> conv_cmplx(const std::vector<T> &a, const std::vector<T>\
58+
\ &b) {\n int N = 1;\n while (N < (int)a.size() + (int)b.size()) N *= 2;\n\
59+
\ std::vector<cmplx> a_(N), b_(N);\n for (int i = 0; i < (int)a.size();\
6160
\ i++) a_[i] = a[i];\n for (int i = 0; i < (int)b.size(); i++) b_[i] = b[i];\n\
6261
\ fft(N, a_, 1);\n fft(N, b_, 1);\n for (int i = 0; i < N; i++) a_[i]\
6362
\ *= b_[i];\n fft(N, a_, -1);\n for (int i = 0; i < N; i++) a_[i] /= N;\n\
@@ -71,7 +70,7 @@ data:
7170
isVerificationFile: false
7271
path: convolution/fft_double.hpp
7372
requiredBy: []
74-
timestamp: '2022-01-08 20:23:44+09:00'
73+
timestamp: '2024-09-22 15:59:27+09:00'
7574
verificationStatus: LIBRARY_ALL_AC
7675
verifiedWith:
7776
- tree/test/frequency_table_of_tree_distance.test.cpp

convolution/hadamard.hpp.md

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ data:
2020
- https://codeforces.com/blog/entry/71899>
2121
- https://csacademy.com/blog/fast-fourier-transform-and-variations-of-it>
2222
bundledCode: "#line 2 \"convolution/hadamard.hpp\"\n#include <cassert>\n#include\
23-
\ <vector>\n\n// CUT begin\n// Fast Walsh-Hadamard transform and its abstraction\n\
24-
// Tutorials: <https://codeforces.com/blog/entry/71899>\n// <https://csacademy.com/blog/fast-fourier-transform-and-variations-of-it>\n\
23+
\ <vector>\n\n// Fast Walsh-Hadamard transform and its abstraction\n// Tutorials:\
24+
\ <https://codeforces.com/blog/entry/71899>\n// <https://csacademy.com/blog/fast-fourier-transform-and-variations-of-it>\n\
2525
template <typename T, typename F> void abstract_fwht(std::vector<T> &seq, F f)\
2626
\ {\n const int n = seq.size();\n assert(__builtin_popcount(n) == 1);\n\
2727
\ for (int w = 1; w < n; w *= 2) {\n for (int i = 0; i < n; i += w *\
28-
\ 2) {\n for (int j = 0; j < w; j++) { f(seq[i + j], seq[i + j + w]);\
29-
\ }\n }\n }\n}\n\ntemplate <typename T, typename F1, typename F2>\n\
28+
\ 2) {\n for (int j = 0; j < w; j++) f(seq.at(i + j), seq.at(i + j\
29+
\ + w));\n }\n }\n}\n\ntemplate <typename T, typename F1, typename F2>\n\
3030
std::vector<T> bitwise_conv(std::vector<T> x, std::vector<T> y, F1 f, F2 finv)\
3131
\ {\n const int n = x.size();\n assert(__builtin_popcount(n) == 1);\n \
3232
\ assert(x.size() == y.size());\n if (x == y) {\n abstract_fwht(x,\
3333
\ f), y = x;\n } else {\n abstract_fwht(x, f), abstract_fwht(y, f);\n\
34-
\ }\n for (size_t i = 0; i < x.size(); i++) { x[i] *= y[i]; }\n abstract_fwht(x,\
34+
\ }\n for (int i = 0; i < (int)x.size(); i++) x.at(i) *= y.at(i);\n abstract_fwht(x,\
3535
\ finv);\n return x;\n}\n\n// bitwise xor convolution (FWHT-based)\n// ret[i]\
3636
\ = \\sum_j x[j] * y[i ^ j]\n// if T is integer, ||x||_1 * ||y||_1 * 2 < numeric_limits<T>::max()\n\
3737
template <typename T> std::vector<T> xorconv(std::vector<T> x, std::vector<T>\
@@ -41,25 +41,24 @@ data:
4141
\ complexity of division by 2 when T is ModInt\n };\n return bitwise_conv(x,\
4242
\ y, f, finv);\n}\n\n// bitwise AND conolution\n// ret[i] = \\sum_{(j & k) ==\
4343
\ i} x[j] * y[k]\ntemplate <typename T> std::vector<T> andconv(std::vector<T>\
44-
\ x, std::vector<T> y) {\n return bitwise_conv(\n x, y, [](T &lo, T\
45-
\ &hi) { lo += hi; }, [](T &lo, T &hi) { lo -= hi; });\n}\n\n// bitwise OR convolution\n\
44+
\ x, std::vector<T> y) {\n return bitwise_conv(x, y, [](T &lo, T &hi) { lo\
45+
\ += hi; }, [](T &lo, T &hi) { lo -= hi; });\n}\n\n// bitwise OR convolution\n\
4646
// ret[i] = \\sum_{(j | k) == i} x[j] * y[k]\ntemplate <typename T> std::vector<T>\
47-
\ orconv(std::vector<T> x, std::vector<T> y) {\n return bitwise_conv(\n \
48-
\ x, y, [](T &lo, T &hi) { hi += lo; }, [](T &lo, T &hi) { hi -= lo; });\n\
49-
}\n"
50-
code: "#pragma once\n#include <cassert>\n#include <vector>\n\n// CUT begin\n// Fast\
51-
\ Walsh-Hadamard transform and its abstraction\n// Tutorials: <https://codeforces.com/blog/entry/71899>\n\
47+
\ orconv(std::vector<T> x, std::vector<T> y) {\n return bitwise_conv(x, y,\
48+
\ [](T &lo, T &hi) { hi += lo; }, [](T &lo, T &hi) { hi -= lo; });\n}\n"
49+
code: "#pragma once\n#include <cassert>\n#include <vector>\n\n// Fast Walsh-Hadamard\
50+
\ transform and its abstraction\n// Tutorials: <https://codeforces.com/blog/entry/71899>\n\
5251
// <https://csacademy.com/blog/fast-fourier-transform-and-variations-of-it>\n\
5352
template <typename T, typename F> void abstract_fwht(std::vector<T> &seq, F f)\
5453
\ {\n const int n = seq.size();\n assert(__builtin_popcount(n) == 1);\n\
5554
\ for (int w = 1; w < n; w *= 2) {\n for (int i = 0; i < n; i += w *\
56-
\ 2) {\n for (int j = 0; j < w; j++) { f(seq[i + j], seq[i + j + w]);\
57-
\ }\n }\n }\n}\n\ntemplate <typename T, typename F1, typename F2>\n\
55+
\ 2) {\n for (int j = 0; j < w; j++) f(seq.at(i + j), seq.at(i + j\
56+
\ + w));\n }\n }\n}\n\ntemplate <typename T, typename F1, typename F2>\n\
5857
std::vector<T> bitwise_conv(std::vector<T> x, std::vector<T> y, F1 f, F2 finv)\
5958
\ {\n const int n = x.size();\n assert(__builtin_popcount(n) == 1);\n \
6059
\ assert(x.size() == y.size());\n if (x == y) {\n abstract_fwht(x,\
6160
\ f), y = x;\n } else {\n abstract_fwht(x, f), abstract_fwht(y, f);\n\
62-
\ }\n for (size_t i = 0; i < x.size(); i++) { x[i] *= y[i]; }\n abstract_fwht(x,\
61+
\ }\n for (int i = 0; i < (int)x.size(); i++) x.at(i) *= y.at(i);\n abstract_fwht(x,\
6362
\ finv);\n return x;\n}\n\n// bitwise xor convolution (FWHT-based)\n// ret[i]\
6463
\ = \\sum_j x[j] * y[i ^ j]\n// if T is integer, ||x||_1 * ||y||_1 * 2 < numeric_limits<T>::max()\n\
6564
template <typename T> std::vector<T> xorconv(std::vector<T> x, std::vector<T>\
@@ -69,17 +68,16 @@ data:
6968
\ complexity of division by 2 when T is ModInt\n };\n return bitwise_conv(x,\
7069
\ y, f, finv);\n}\n\n// bitwise AND conolution\n// ret[i] = \\sum_{(j & k) ==\
7170
\ i} x[j] * y[k]\ntemplate <typename T> std::vector<T> andconv(std::vector<T>\
72-
\ x, std::vector<T> y) {\n return bitwise_conv(\n x, y, [](T &lo, T\
73-
\ &hi) { lo += hi; }, [](T &lo, T &hi) { lo -= hi; });\n}\n\n// bitwise OR convolution\n\
71+
\ x, std::vector<T> y) {\n return bitwise_conv(x, y, [](T &lo, T &hi) { lo\
72+
\ += hi; }, [](T &lo, T &hi) { lo -= hi; });\n}\n\n// bitwise OR convolution\n\
7473
// ret[i] = \\sum_{(j | k) == i} x[j] * y[k]\ntemplate <typename T> std::vector<T>\
75-
\ orconv(std::vector<T> x, std::vector<T> y) {\n return bitwise_conv(\n \
76-
\ x, y, [](T &lo, T &hi) { hi += lo; }, [](T &lo, T &hi) { hi -= lo; });\n\
77-
}\n"
74+
\ orconv(std::vector<T> x, std::vector<T> y) {\n return bitwise_conv(x, y,\
75+
\ [](T &lo, T &hi) { hi += lo; }, [](T &lo, T &hi) { hi -= lo; });\n}\n"
7876
dependsOn: []
7977
isVerificationFile: false
8078
path: convolution/hadamard.hpp
8179
requiredBy: []
82-
timestamp: '2022-01-08 20:23:44+09:00'
80+
timestamp: '2024-09-22 16:07:49+09:00'
8381
verificationStatus: LIBRARY_ALL_AC
8482
verifiedWith:
8583
- convolution/test/bitwise_xor_conv.test.cpp

convolution/test/bitwise_and_conv.test.cpp.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -112,18 +112,18 @@ data:
112112
\ ModInt<md>::facinvs = {1};\ntemplate <int md> std::vector<ModInt<md>> ModInt<md>::invs\
113113
\ = {0};\n\nusing ModInt998244353 = ModInt<998244353>;\n// using mint = ModInt<998244353>;\n\
114114
// using mint = ModInt<1000000007>;\n#line 4 \"convolution/hadamard.hpp\"\n\n\
115-
// CUT begin\n// Fast Walsh-Hadamard transform and its abstraction\n// Tutorials:\
116-
\ <https://codeforces.com/blog/entry/71899>\n// <https://csacademy.com/blog/fast-fourier-transform-and-variations-of-it>\n\
115+
// Fast Walsh-Hadamard transform and its abstraction\n// Tutorials: <https://codeforces.com/blog/entry/71899>\n\
116+
// <https://csacademy.com/blog/fast-fourier-transform-and-variations-of-it>\n\
117117
template <typename T, typename F> void abstract_fwht(std::vector<T> &seq, F f)\
118118
\ {\n const int n = seq.size();\n assert(__builtin_popcount(n) == 1);\n\
119119
\ for (int w = 1; w < n; w *= 2) {\n for (int i = 0; i < n; i += w *\
120-
\ 2) {\n for (int j = 0; j < w; j++) { f(seq[i + j], seq[i + j + w]);\
121-
\ }\n }\n }\n}\n\ntemplate <typename T, typename F1, typename F2>\n\
120+
\ 2) {\n for (int j = 0; j < w; j++) f(seq.at(i + j), seq.at(i + j\
121+
\ + w));\n }\n }\n}\n\ntemplate <typename T, typename F1, typename F2>\n\
122122
std::vector<T> bitwise_conv(std::vector<T> x, std::vector<T> y, F1 f, F2 finv)\
123123
\ {\n const int n = x.size();\n assert(__builtin_popcount(n) == 1);\n \
124124
\ assert(x.size() == y.size());\n if (x == y) {\n abstract_fwht(x,\
125125
\ f), y = x;\n } else {\n abstract_fwht(x, f), abstract_fwht(y, f);\n\
126-
\ }\n for (size_t i = 0; i < x.size(); i++) { x[i] *= y[i]; }\n abstract_fwht(x,\
126+
\ }\n for (int i = 0; i < (int)x.size(); i++) x.at(i) *= y.at(i);\n abstract_fwht(x,\
127127
\ finv);\n return x;\n}\n\n// bitwise xor convolution (FWHT-based)\n// ret[i]\
128128
\ = \\sum_j x[j] * y[i ^ j]\n// if T is integer, ||x||_1 * ||y||_1 * 2 < numeric_limits<T>::max()\n\
129129
template <typename T> std::vector<T> xorconv(std::vector<T> x, std::vector<T>\
@@ -133,14 +133,14 @@ data:
133133
\ complexity of division by 2 when T is ModInt\n };\n return bitwise_conv(x,\
134134
\ y, f, finv);\n}\n\n// bitwise AND conolution\n// ret[i] = \\sum_{(j & k) ==\
135135
\ i} x[j] * y[k]\ntemplate <typename T> std::vector<T> andconv(std::vector<T>\
136-
\ x, std::vector<T> y) {\n return bitwise_conv(\n x, y, [](T &lo, T\
137-
\ &hi) { lo += hi; }, [](T &lo, T &hi) { lo -= hi; });\n}\n\n// bitwise OR convolution\n\
136+
\ x, std::vector<T> y) {\n return bitwise_conv(x, y, [](T &lo, T &hi) { lo\
137+
\ += hi; }, [](T &lo, T &hi) { lo -= hi; });\n}\n\n// bitwise OR convolution\n\
138138
// ret[i] = \\sum_{(j | k) == i} x[j] * y[k]\ntemplate <typename T> std::vector<T>\
139-
\ orconv(std::vector<T> x, std::vector<T> y) {\n return bitwise_conv(\n \
140-
\ x, y, [](T &lo, T &hi) { hi += lo; }, [](T &lo, T &hi) { hi -= lo; });\n\
141-
}\n#line 5 \"convolution/test/bitwise_and_conv.test.cpp\"\nusing namespace std;\n\
142-
\nint main() {\n cin.tie(nullptr), ios::sync_with_stdio(false);\n int N;\n\
143-
\ cin >> N;\n vector<ModInt<998244353>> A(1 << N), B(1 << N);\n for (auto\
139+
\ orconv(std::vector<T> x, std::vector<T> y) {\n return bitwise_conv(x, y,\
140+
\ [](T &lo, T &hi) { hi += lo; }, [](T &lo, T &hi) { hi -= lo; });\n}\n#line 5\
141+
\ \"convolution/test/bitwise_and_conv.test.cpp\"\nusing namespace std;\n\nint\
142+
\ main() {\n cin.tie(nullptr), ios::sync_with_stdio(false);\n int N;\n \
143+
\ cin >> N;\n vector<ModInt<998244353>> A(1 << N), B(1 << N);\n for (auto\
144144
\ &x : A) cin >> x;\n for (auto &x : B) cin >> x;\n\n for (auto x : andconv(A,\
145145
\ B)) cout << x << ' ';\n}\n"
146146
code: "#define PROBLEM \"https://judge.yosupo.jp/problem/bitwise_and_convolution\"\
@@ -155,7 +155,7 @@ data:
155155
isVerificationFile: true
156156
path: convolution/test/bitwise_and_conv.test.cpp
157157
requiredBy: []
158-
timestamp: '2023-12-26 21:26:22+09:00'
158+
timestamp: '2024-09-22 16:07:49+09:00'
159159
verificationStatus: TEST_ACCEPTED
160160
verifiedWith: []
161161
documentation_of: convolution/test/bitwise_and_conv.test.cpp

0 commit comments

Comments
 (0)