From 03628bb5cd87022c256bd60f058c38f8f67f4ee6 Mon Sep 17 00:00:00 2001 From: GitHub Date: Sun, 22 Sep 2024 07:16:14 +0000 Subject: [PATCH] [auto-verifier] docs commit d4836fa8b1381fd38548b0631d73e47aa7aea370 --- README.md | 2 +- convolution/fft_double.hpp.md | 63 ++-- convolution/hadamard.hpp.md | 40 ++- convolution/test/bitwise_and_conv.test.cpp.md | 26 +- convolution/test/bitwise_xor_conv.test.cpp.md | 26 +- convolution/test/hadamard_xor.test.cpp.md | 22 +- data_structure/rbst_fast.cpp.md | 276 ------------------ flow/networksimplex.hpp.md | 6 +- flow/test/bflow_ns.test.cpp.md | 4 +- flow/test/mcf_ns.test.cpp.md | 4 +- index.md | 3 - multithread/multithread_example.cpp.md | 10 +- string/palindromic_tree.hpp.md | 48 +-- .../palindromic_tree.yuki2606.test.cpp.md | 8 +- .../test/palindromic_tree.yuki263.test.cpp.md | 8 +- ...equency_table_of_tree_distance.test.cpp.md | 33 +-- 16 files changed, 148 insertions(+), 431 deletions(-) delete mode 100644 data_structure/rbst_fast.cpp.md diff --git a/README.md b/README.md index d443909d..460e6216 100644 --- a/README.md +++ b/README.md @@ -36,4 +36,4 @@ Except such snippets, the programs written by the owner of the repo is under the ## Formatting -`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. +`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. diff --git a/convolution/fft_double.hpp.md b/convolution/fft_double.hpp.md index 96a5adfb..d555c396 100644 --- a/convolution/fft_double.hpp.md +++ b/convolution/fft_double.hpp.md @@ -14,23 +14,23 @@ data: - http://kirika-comp.hatenablog.com/entry/2018/03/12/210446 - https://atcoder.jp/contests/atc001/submissions/9243440 bundledCode: "#line 2 \"convolution/fft_double.hpp\"\n#include \n#include\ - \ \n#include \n\n// CUT begin\n// Convolution by FFT (Fast Fourier\ - \ Transform)\n// Algorithm based on http://kirika-comp.hatenablog.com/entry/2018/03/12/210446\n\ + \ \n#include \n\n// Convolution by FFT (Fast Fourier Transform)\n\ + // Algorithm based on http://kirika-comp.hatenablog.com/entry/2018/03/12/210446\n\ // Verified: ATC001C (168 ms) https://atcoder.jp/contests/atc001/submissions/9243440\n\ using cmplx = std::complex;\nvoid fft(int N, std::vector &a, double\ \ dir) {\n int i = 0;\n for (int j = 1; j < N - 1; j++) {\n for (int\ - \ k = N >> 1; k > (i ^= k); k >>= 1)\n ;\n if (j < i) std::swap(a[i],\ - \ a[j]);\n }\n\n std::vector zeta_pow(N);\n for (int i = 0; i\ - \ < N; i++) {\n double theta = M_PI / N * i * dir;\n zeta_pow[i]\ - \ = {cos(theta), sin(theta)};\n }\n\n for (int m = 1; m < N; m *= 2) {\n\ - \ for (int y = 0; y < m; y++) {\n cmplx fac = zeta_pow[N / m\ - \ * y];\n for (int x = 0; x < N; x += 2 * m) {\n int\ - \ u = x + y;\n int v = x + y + m;\n cmplx s = a[u]\ - \ + fac * a[v];\n cmplx t = a[u] - fac * a[v];\n \ - \ a[u] = s;\n a[v] = t;\n }\n }\n }\n}\n\ - template \nstd::vector conv_cmplx(const std::vector &a,\ - \ const std::vector &b) {\n int N = 1;\n while (N < (int)a.size() + (int)b.size())\ - \ N *= 2;\n std::vector a_(N), b_(N);\n for (int i = 0; i < (int)a.size();\ + \ k = N >> 1; k > (i ^= k); k >>= 1) {}\n if (j < i) std::swap(a[i], a[j]);\n\ + \ }\n\n std::vector zeta_pow(N);\n for (int i = 0; i < N; i++)\ + \ {\n double theta = M_PI / N * i * dir;\n zeta_pow[i] = {cos(theta),\ + \ sin(theta)};\n }\n\n for (int m = 1; m < N; m *= 2) {\n for (int\ + \ y = 0; y < m; y++) {\n cmplx fac = zeta_pow[N / m * y];\n \ + \ for (int x = 0; x < N; x += 2 * m) {\n int u = x + y;\n \ + \ int v = x + y + m;\n cmplx s = a[u] + fac * a[v];\n\ + \ cmplx t = a[u] - fac * a[v];\n a[u] = s;\n \ + \ a[v] = t;\n }\n }\n }\n}\ntemplate \nstd::vector conv_cmplx(const std::vector &a, const std::vector\ + \ &b) {\n int N = 1;\n while (N < (int)a.size() + (int)b.size()) N *= 2;\n\ + \ std::vector a_(N), b_(N);\n for (int i = 0; i < (int)a.size();\ \ i++) a_[i] = a[i];\n for (int i = 0; i < (int)b.size(); i++) b_[i] = b[i];\n\ \ fft(N, a_, 1);\n fft(N, b_, 1);\n for (int i = 0; i < N; i++) a_[i]\ \ *= b_[i];\n fft(N, a_, -1);\n for (int i = 0; i < N; i++) a_[i] /= N;\n\ @@ -41,23 +41,22 @@ data: \ for (int i = 0; i < (int)ans.size(); i++) ret[i] = floor(ans[i].real() + 0.5);\n\ \ ret.resize(a.size() + b.size() - 1);\n return ret;\n}\n" code: "#pragma once\n#include \n#include \n#include \n\ - \n// CUT begin\n// Convolution by FFT (Fast Fourier Transform)\n// Algorithm based\ - \ on http://kirika-comp.hatenablog.com/entry/2018/03/12/210446\n// Verified: ATC001C\ - \ (168 ms) https://atcoder.jp/contests/atc001/submissions/9243440\nusing cmplx\ - \ = std::complex;\nvoid fft(int N, std::vector &a, double dir)\ - \ {\n int i = 0;\n for (int j = 1; j < N - 1; j++) {\n for (int k\ - \ = N >> 1; k > (i ^= k); k >>= 1)\n ;\n if (j < i) std::swap(a[i],\ - \ a[j]);\n }\n\n std::vector zeta_pow(N);\n for (int i = 0; i\ - \ < N; i++) {\n double theta = M_PI / N * i * dir;\n zeta_pow[i]\ - \ = {cos(theta), sin(theta)};\n }\n\n for (int m = 1; m < N; m *= 2) {\n\ - \ for (int y = 0; y < m; y++) {\n cmplx fac = zeta_pow[N / m\ - \ * y];\n for (int x = 0; x < N; x += 2 * m) {\n int\ - \ u = x + y;\n int v = x + y + m;\n cmplx s = a[u]\ - \ + fac * a[v];\n cmplx t = a[u] - fac * a[v];\n \ - \ a[u] = s;\n a[v] = t;\n }\n }\n }\n}\n\ - template \nstd::vector conv_cmplx(const std::vector &a,\ - \ const std::vector &b) {\n int N = 1;\n while (N < (int)a.size() + (int)b.size())\ - \ N *= 2;\n std::vector a_(N), b_(N);\n for (int i = 0; i < (int)a.size();\ + \n// Convolution by FFT (Fast Fourier Transform)\n// Algorithm based on http://kirika-comp.hatenablog.com/entry/2018/03/12/210446\n\ + // Verified: ATC001C (168 ms) https://atcoder.jp/contests/atc001/submissions/9243440\n\ + using cmplx = std::complex;\nvoid fft(int N, std::vector &a, double\ + \ dir) {\n int i = 0;\n for (int j = 1; j < N - 1; j++) {\n for (int\ + \ k = N >> 1; k > (i ^= k); k >>= 1) {}\n if (j < i) std::swap(a[i], a[j]);\n\ + \ }\n\n std::vector zeta_pow(N);\n for (int i = 0; i < N; i++)\ + \ {\n double theta = M_PI / N * i * dir;\n zeta_pow[i] = {cos(theta),\ + \ sin(theta)};\n }\n\n for (int m = 1; m < N; m *= 2) {\n for (int\ + \ y = 0; y < m; y++) {\n cmplx fac = zeta_pow[N / m * y];\n \ + \ for (int x = 0; x < N; x += 2 * m) {\n int u = x + y;\n \ + \ int v = x + y + m;\n cmplx s = a[u] + fac * a[v];\n\ + \ cmplx t = a[u] - fac * a[v];\n a[u] = s;\n \ + \ a[v] = t;\n }\n }\n }\n}\ntemplate \nstd::vector conv_cmplx(const std::vector &a, const std::vector\ + \ &b) {\n int N = 1;\n while (N < (int)a.size() + (int)b.size()) N *= 2;\n\ + \ std::vector a_(N), b_(N);\n for (int i = 0; i < (int)a.size();\ \ i++) a_[i] = a[i];\n for (int i = 0; i < (int)b.size(); i++) b_[i] = b[i];\n\ \ fft(N, a_, 1);\n fft(N, b_, 1);\n for (int i = 0; i < N; i++) a_[i]\ \ *= b_[i];\n fft(N, a_, -1);\n for (int i = 0; i < N; i++) a_[i] /= N;\n\ @@ -71,7 +70,7 @@ data: isVerificationFile: false path: convolution/fft_double.hpp requiredBy: [] - timestamp: '2022-01-08 20:23:44+09:00' + timestamp: '2024-09-22 15:59:27+09:00' verificationStatus: LIBRARY_ALL_AC verifiedWith: - tree/test/frequency_table_of_tree_distance.test.cpp diff --git a/convolution/hadamard.hpp.md b/convolution/hadamard.hpp.md index 1d43d373..dfe9db37 100644 --- a/convolution/hadamard.hpp.md +++ b/convolution/hadamard.hpp.md @@ -20,18 +20,18 @@ data: - https://codeforces.com/blog/entry/71899> - https://csacademy.com/blog/fast-fourier-transform-and-variations-of-it> bundledCode: "#line 2 \"convolution/hadamard.hpp\"\n#include \n#include\ - \ \n\n// CUT begin\n// Fast Walsh-Hadamard transform and its abstraction\n\ - // Tutorials: \n// \n\ + \ \n\n// Fast Walsh-Hadamard transform and its abstraction\n// Tutorials:\ + \ \n// \n\ template void abstract_fwht(std::vector &seq, F f)\ \ {\n const int n = seq.size();\n assert(__builtin_popcount(n) == 1);\n\ \ for (int w = 1; w < n; w *= 2) {\n for (int i = 0; i < n; i += w *\ - \ 2) {\n for (int j = 0; j < w; j++) { f(seq[i + j], seq[i + j + w]);\ - \ }\n }\n }\n}\n\ntemplate \n\ + \ 2) {\n for (int j = 0; j < w; j++) f(seq.at(i + j), seq.at(i + j\ + \ + w));\n }\n }\n}\n\ntemplate \n\ std::vector bitwise_conv(std::vector x, std::vector y, F1 f, F2 finv)\ \ {\n const int n = x.size();\n assert(__builtin_popcount(n) == 1);\n \ \ assert(x.size() == y.size());\n if (x == y) {\n abstract_fwht(x,\ \ f), y = x;\n } else {\n abstract_fwht(x, f), abstract_fwht(y, f);\n\ - \ }\n for (size_t i = 0; i < x.size(); i++) { x[i] *= y[i]; }\n abstract_fwht(x,\ + \ }\n for (int i = 0; i < (int)x.size(); i++) x.at(i) *= y.at(i);\n abstract_fwht(x,\ \ finv);\n return x;\n}\n\n// bitwise xor convolution (FWHT-based)\n// ret[i]\ \ = \\sum_j x[j] * y[i ^ j]\n// if T is integer, ||x||_1 * ||y||_1 * 2 < numeric_limits::max()\n\ template std::vector xorconv(std::vector x, std::vector\ @@ -41,25 +41,24 @@ data: \ complexity of division by 2 when T is ModInt\n };\n return bitwise_conv(x,\ \ y, f, finv);\n}\n\n// bitwise AND conolution\n// ret[i] = \\sum_{(j & k) ==\ \ i} x[j] * y[k]\ntemplate std::vector andconv(std::vector\ - \ x, std::vector y) {\n return bitwise_conv(\n x, y, [](T &lo, T\ - \ &hi) { lo += hi; }, [](T &lo, T &hi) { lo -= hi; });\n}\n\n// bitwise OR convolution\n\ + \ x, std::vector y) {\n return bitwise_conv(x, y, [](T &lo, T &hi) { lo\ + \ += hi; }, [](T &lo, T &hi) { lo -= hi; });\n}\n\n// bitwise OR convolution\n\ // ret[i] = \\sum_{(j | k) == i} x[j] * y[k]\ntemplate std::vector\ - \ orconv(std::vector x, std::vector y) {\n return bitwise_conv(\n \ - \ x, y, [](T &lo, T &hi) { hi += lo; }, [](T &lo, T &hi) { hi -= lo; });\n\ - }\n" - code: "#pragma once\n#include \n#include \n\n// CUT begin\n// Fast\ - \ Walsh-Hadamard transform and its abstraction\n// Tutorials: \n\ + \ orconv(std::vector x, std::vector y) {\n return bitwise_conv(x, y,\ + \ [](T &lo, T &hi) { hi += lo; }, [](T &lo, T &hi) { hi -= lo; });\n}\n" + code: "#pragma once\n#include \n#include \n\n// Fast Walsh-Hadamard\ + \ transform and its abstraction\n// Tutorials: \n\ // \n\ template void abstract_fwht(std::vector &seq, F f)\ \ {\n const int n = seq.size();\n assert(__builtin_popcount(n) == 1);\n\ \ for (int w = 1; w < n; w *= 2) {\n for (int i = 0; i < n; i += w *\ - \ 2) {\n for (int j = 0; j < w; j++) { f(seq[i + j], seq[i + j + w]);\ - \ }\n }\n }\n}\n\ntemplate \n\ + \ 2) {\n for (int j = 0; j < w; j++) f(seq.at(i + j), seq.at(i + j\ + \ + w));\n }\n }\n}\n\ntemplate \n\ std::vector bitwise_conv(std::vector x, std::vector y, F1 f, F2 finv)\ \ {\n const int n = x.size();\n assert(__builtin_popcount(n) == 1);\n \ \ assert(x.size() == y.size());\n if (x == y) {\n abstract_fwht(x,\ \ f), y = x;\n } else {\n abstract_fwht(x, f), abstract_fwht(y, f);\n\ - \ }\n for (size_t i = 0; i < x.size(); i++) { x[i] *= y[i]; }\n abstract_fwht(x,\ + \ }\n for (int i = 0; i < (int)x.size(); i++) x.at(i) *= y.at(i);\n abstract_fwht(x,\ \ finv);\n return x;\n}\n\n// bitwise xor convolution (FWHT-based)\n// ret[i]\ \ = \\sum_j x[j] * y[i ^ j]\n// if T is integer, ||x||_1 * ||y||_1 * 2 < numeric_limits::max()\n\ template std::vector xorconv(std::vector x, std::vector\ @@ -69,17 +68,16 @@ data: \ complexity of division by 2 when T is ModInt\n };\n return bitwise_conv(x,\ \ y, f, finv);\n}\n\n// bitwise AND conolution\n// ret[i] = \\sum_{(j & k) ==\ \ i} x[j] * y[k]\ntemplate std::vector andconv(std::vector\ - \ x, std::vector y) {\n return bitwise_conv(\n x, y, [](T &lo, T\ - \ &hi) { lo += hi; }, [](T &lo, T &hi) { lo -= hi; });\n}\n\n// bitwise OR convolution\n\ + \ x, std::vector y) {\n return bitwise_conv(x, y, [](T &lo, T &hi) { lo\ + \ += hi; }, [](T &lo, T &hi) { lo -= hi; });\n}\n\n// bitwise OR convolution\n\ // ret[i] = \\sum_{(j | k) == i} x[j] * y[k]\ntemplate std::vector\ - \ orconv(std::vector x, std::vector y) {\n return bitwise_conv(\n \ - \ x, y, [](T &lo, T &hi) { hi += lo; }, [](T &lo, T &hi) { hi -= lo; });\n\ - }\n" + \ orconv(std::vector x, std::vector y) {\n return bitwise_conv(x, y,\ + \ [](T &lo, T &hi) { hi += lo; }, [](T &lo, T &hi) { hi -= lo; });\n}\n" dependsOn: [] isVerificationFile: false path: convolution/hadamard.hpp requiredBy: [] - timestamp: '2022-01-08 20:23:44+09:00' + timestamp: '2024-09-22 16:07:49+09:00' verificationStatus: LIBRARY_ALL_AC verifiedWith: - convolution/test/bitwise_xor_conv.test.cpp diff --git a/convolution/test/bitwise_and_conv.test.cpp.md b/convolution/test/bitwise_and_conv.test.cpp.md index f8686739..26b5e965 100644 --- a/convolution/test/bitwise_and_conv.test.cpp.md +++ b/convolution/test/bitwise_and_conv.test.cpp.md @@ -112,18 +112,18 @@ data: \ ModInt::facinvs = {1};\ntemplate std::vector> ModInt::invs\ \ = {0};\n\nusing ModInt998244353 = ModInt<998244353>;\n// using mint = ModInt<998244353>;\n\ // using mint = ModInt<1000000007>;\n#line 4 \"convolution/hadamard.hpp\"\n\n\ - // CUT begin\n// Fast Walsh-Hadamard transform and its abstraction\n// Tutorials:\ - \ \n// \n\ + // Fast Walsh-Hadamard transform and its abstraction\n// Tutorials: \n\ + // \n\ template void abstract_fwht(std::vector &seq, F f)\ \ {\n const int n = seq.size();\n assert(__builtin_popcount(n) == 1);\n\ \ for (int w = 1; w < n; w *= 2) {\n for (int i = 0; i < n; i += w *\ - \ 2) {\n for (int j = 0; j < w; j++) { f(seq[i + j], seq[i + j + w]);\ - \ }\n }\n }\n}\n\ntemplate \n\ + \ 2) {\n for (int j = 0; j < w; j++) f(seq.at(i + j), seq.at(i + j\ + \ + w));\n }\n }\n}\n\ntemplate \n\ std::vector bitwise_conv(std::vector x, std::vector y, F1 f, F2 finv)\ \ {\n const int n = x.size();\n assert(__builtin_popcount(n) == 1);\n \ \ assert(x.size() == y.size());\n if (x == y) {\n abstract_fwht(x,\ \ f), y = x;\n } else {\n abstract_fwht(x, f), abstract_fwht(y, f);\n\ - \ }\n for (size_t i = 0; i < x.size(); i++) { x[i] *= y[i]; }\n abstract_fwht(x,\ + \ }\n for (int i = 0; i < (int)x.size(); i++) x.at(i) *= y.at(i);\n abstract_fwht(x,\ \ finv);\n return x;\n}\n\n// bitwise xor convolution (FWHT-based)\n// ret[i]\ \ = \\sum_j x[j] * y[i ^ j]\n// if T is integer, ||x||_1 * ||y||_1 * 2 < numeric_limits::max()\n\ template std::vector xorconv(std::vector x, std::vector\ @@ -133,14 +133,14 @@ data: \ complexity of division by 2 when T is ModInt\n };\n return bitwise_conv(x,\ \ y, f, finv);\n}\n\n// bitwise AND conolution\n// ret[i] = \\sum_{(j & k) ==\ \ i} x[j] * y[k]\ntemplate std::vector andconv(std::vector\ - \ x, std::vector y) {\n return bitwise_conv(\n x, y, [](T &lo, T\ - \ &hi) { lo += hi; }, [](T &lo, T &hi) { lo -= hi; });\n}\n\n// bitwise OR convolution\n\ + \ x, std::vector y) {\n return bitwise_conv(x, y, [](T &lo, T &hi) { lo\ + \ += hi; }, [](T &lo, T &hi) { lo -= hi; });\n}\n\n// bitwise OR convolution\n\ // ret[i] = \\sum_{(j | k) == i} x[j] * y[k]\ntemplate std::vector\ - \ orconv(std::vector x, std::vector y) {\n return bitwise_conv(\n \ - \ x, y, [](T &lo, T &hi) { hi += lo; }, [](T &lo, T &hi) { hi -= lo; });\n\ - }\n#line 5 \"convolution/test/bitwise_and_conv.test.cpp\"\nusing namespace std;\n\ - \nint main() {\n cin.tie(nullptr), ios::sync_with_stdio(false);\n int N;\n\ - \ cin >> N;\n vector> A(1 << N), B(1 << N);\n for (auto\ + \ orconv(std::vector x, std::vector y) {\n return bitwise_conv(x, y,\ + \ [](T &lo, T &hi) { hi += lo; }, [](T &lo, T &hi) { hi -= lo; });\n}\n#line 5\ + \ \"convolution/test/bitwise_and_conv.test.cpp\"\nusing namespace std;\n\nint\ + \ main() {\n cin.tie(nullptr), ios::sync_with_stdio(false);\n int N;\n \ + \ cin >> N;\n vector> A(1 << N), B(1 << N);\n for (auto\ \ &x : A) cin >> x;\n for (auto &x : B) cin >> x;\n\n for (auto x : andconv(A,\ \ B)) cout << x << ' ';\n}\n" code: "#define PROBLEM \"https://judge.yosupo.jp/problem/bitwise_and_convolution\"\ @@ -155,7 +155,7 @@ data: isVerificationFile: true path: convolution/test/bitwise_and_conv.test.cpp requiredBy: [] - timestamp: '2023-12-26 21:26:22+09:00' + timestamp: '2024-09-22 16:07:49+09:00' verificationStatus: TEST_ACCEPTED verifiedWith: [] documentation_of: convolution/test/bitwise_and_conv.test.cpp diff --git a/convolution/test/bitwise_xor_conv.test.cpp.md b/convolution/test/bitwise_xor_conv.test.cpp.md index 8940762a..ce8f3377 100644 --- a/convolution/test/bitwise_xor_conv.test.cpp.md +++ b/convolution/test/bitwise_xor_conv.test.cpp.md @@ -112,18 +112,18 @@ data: \ ModInt::facinvs = {1};\ntemplate std::vector> ModInt::invs\ \ = {0};\n\nusing ModInt998244353 = ModInt<998244353>;\n// using mint = ModInt<998244353>;\n\ // using mint = ModInt<1000000007>;\n#line 4 \"convolution/hadamard.hpp\"\n\n\ - // CUT begin\n// Fast Walsh-Hadamard transform and its abstraction\n// Tutorials:\ - \ \n// \n\ + // Fast Walsh-Hadamard transform and its abstraction\n// Tutorials: \n\ + // \n\ template void abstract_fwht(std::vector &seq, F f)\ \ {\n const int n = seq.size();\n assert(__builtin_popcount(n) == 1);\n\ \ for (int w = 1; w < n; w *= 2) {\n for (int i = 0; i < n; i += w *\ - \ 2) {\n for (int j = 0; j < w; j++) { f(seq[i + j], seq[i + j + w]);\ - \ }\n }\n }\n}\n\ntemplate \n\ + \ 2) {\n for (int j = 0; j < w; j++) f(seq.at(i + j), seq.at(i + j\ + \ + w));\n }\n }\n}\n\ntemplate \n\ std::vector bitwise_conv(std::vector x, std::vector y, F1 f, F2 finv)\ \ {\n const int n = x.size();\n assert(__builtin_popcount(n) == 1);\n \ \ assert(x.size() == y.size());\n if (x == y) {\n abstract_fwht(x,\ \ f), y = x;\n } else {\n abstract_fwht(x, f), abstract_fwht(y, f);\n\ - \ }\n for (size_t i = 0; i < x.size(); i++) { x[i] *= y[i]; }\n abstract_fwht(x,\ + \ }\n for (int i = 0; i < (int)x.size(); i++) x.at(i) *= y.at(i);\n abstract_fwht(x,\ \ finv);\n return x;\n}\n\n// bitwise xor convolution (FWHT-based)\n// ret[i]\ \ = \\sum_j x[j] * y[i ^ j]\n// if T is integer, ||x||_1 * ||y||_1 * 2 < numeric_limits::max()\n\ template std::vector xorconv(std::vector x, std::vector\ @@ -133,14 +133,14 @@ data: \ complexity of division by 2 when T is ModInt\n };\n return bitwise_conv(x,\ \ y, f, finv);\n}\n\n// bitwise AND conolution\n// ret[i] = \\sum_{(j & k) ==\ \ i} x[j] * y[k]\ntemplate std::vector andconv(std::vector\ - \ x, std::vector y) {\n return bitwise_conv(\n x, y, [](T &lo, T\ - \ &hi) { lo += hi; }, [](T &lo, T &hi) { lo -= hi; });\n}\n\n// bitwise OR convolution\n\ + \ x, std::vector y) {\n return bitwise_conv(x, y, [](T &lo, T &hi) { lo\ + \ += hi; }, [](T &lo, T &hi) { lo -= hi; });\n}\n\n// bitwise OR convolution\n\ // ret[i] = \\sum_{(j | k) == i} x[j] * y[k]\ntemplate std::vector\ - \ orconv(std::vector x, std::vector y) {\n return bitwise_conv(\n \ - \ x, y, [](T &lo, T &hi) { hi += lo; }, [](T &lo, T &hi) { hi -= lo; });\n\ - }\n#line 5 \"convolution/test/bitwise_xor_conv.test.cpp\"\nusing namespace std;\n\ - \nint main() {\n cin.tie(nullptr), ios::sync_with_stdio(false);\n int N;\n\ - \ cin >> N;\n vector> A(1 << N), B(1 << N);\n for (auto\ + \ orconv(std::vector x, std::vector y) {\n return bitwise_conv(x, y,\ + \ [](T &lo, T &hi) { hi += lo; }, [](T &lo, T &hi) { hi -= lo; });\n}\n#line 5\ + \ \"convolution/test/bitwise_xor_conv.test.cpp\"\nusing namespace std;\n\nint\ + \ main() {\n cin.tie(nullptr), ios::sync_with_stdio(false);\n int N;\n \ + \ cin >> N;\n vector> A(1 << N), B(1 << N);\n for (auto\ \ &x : A) cin >> x;\n for (auto &x : B) cin >> x;\n\n for (auto x : xorconv(A,\ \ B)) cout << x << ' ';\n}\n" code: "#define PROBLEM \"https://judge.yosupo.jp/problem/bitwise_xor_convolution\"\ @@ -155,7 +155,7 @@ data: isVerificationFile: true path: convolution/test/bitwise_xor_conv.test.cpp requiredBy: [] - timestamp: '2023-12-26 21:26:22+09:00' + timestamp: '2024-09-22 16:07:49+09:00' verificationStatus: TEST_ACCEPTED verifiedWith: [] documentation_of: convolution/test/bitwise_xor_conv.test.cpp diff --git a/convolution/test/hadamard_xor.test.cpp.md b/convolution/test/hadamard_xor.test.cpp.md index e90f762f..61132336 100644 --- a/convolution/test/hadamard_xor.test.cpp.md +++ b/convolution/test/hadamard_xor.test.cpp.md @@ -15,18 +15,18 @@ data: links: - https://yukicoder.me/problems/no/1240 bundledCode: "#line 2 \"convolution/hadamard.hpp\"\n#include \n#include\ - \ \n\n// CUT begin\n// Fast Walsh-Hadamard transform and its abstraction\n\ - // Tutorials: \n// \n\ + \ \n\n// Fast Walsh-Hadamard transform and its abstraction\n// Tutorials:\ + \ \n// \n\ template void abstract_fwht(std::vector &seq, F f)\ \ {\n const int n = seq.size();\n assert(__builtin_popcount(n) == 1);\n\ \ for (int w = 1; w < n; w *= 2) {\n for (int i = 0; i < n; i += w *\ - \ 2) {\n for (int j = 0; j < w; j++) { f(seq[i + j], seq[i + j + w]);\ - \ }\n }\n }\n}\n\ntemplate \n\ + \ 2) {\n for (int j = 0; j < w; j++) f(seq.at(i + j), seq.at(i + j\ + \ + w));\n }\n }\n}\n\ntemplate \n\ std::vector bitwise_conv(std::vector x, std::vector y, F1 f, F2 finv)\ \ {\n const int n = x.size();\n assert(__builtin_popcount(n) == 1);\n \ \ assert(x.size() == y.size());\n if (x == y) {\n abstract_fwht(x,\ \ f), y = x;\n } else {\n abstract_fwht(x, f), abstract_fwht(y, f);\n\ - \ }\n for (size_t i = 0; i < x.size(); i++) { x[i] *= y[i]; }\n abstract_fwht(x,\ + \ }\n for (int i = 0; i < (int)x.size(); i++) x.at(i) *= y.at(i);\n abstract_fwht(x,\ \ finv);\n return x;\n}\n\n// bitwise xor convolution (FWHT-based)\n// ret[i]\ \ = \\sum_j x[j] * y[i ^ j]\n// if T is integer, ||x||_1 * ||y||_1 * 2 < numeric_limits::max()\n\ template std::vector xorconv(std::vector x, std::vector\ @@ -36,12 +36,12 @@ data: \ complexity of division by 2 when T is ModInt\n };\n return bitwise_conv(x,\ \ y, f, finv);\n}\n\n// bitwise AND conolution\n// ret[i] = \\sum_{(j & k) ==\ \ i} x[j] * y[k]\ntemplate std::vector andconv(std::vector\ - \ x, std::vector y) {\n return bitwise_conv(\n x, y, [](T &lo, T\ - \ &hi) { lo += hi; }, [](T &lo, T &hi) { lo -= hi; });\n}\n\n// bitwise OR convolution\n\ + \ x, std::vector y) {\n return bitwise_conv(x, y, [](T &lo, T &hi) { lo\ + \ += hi; }, [](T &lo, T &hi) { lo -= hi; });\n}\n\n// bitwise OR convolution\n\ // ret[i] = \\sum_{(j | k) == i} x[j] * y[k]\ntemplate std::vector\ - \ orconv(std::vector x, std::vector y) {\n return bitwise_conv(\n \ - \ x, y, [](T &lo, T &hi) { hi += lo; }, [](T &lo, T &hi) { hi -= lo; });\n\ - }\n#line 2 \"convolution/test/hadamard_xor.test.cpp\"\n#define PROBLEM \"https://yukicoder.me/problems/no/1240\"\ + \ orconv(std::vector x, std::vector y) {\n return bitwise_conv(x, y,\ + \ [](T &lo, T &hi) { hi += lo; }, [](T &lo, T &hi) { hi -= lo; });\n}\n#line 2\ + \ \"convolution/test/hadamard_xor.test.cpp\"\n#define PROBLEM \"https://yukicoder.me/problems/no/1240\"\ \n#include \nusing namespace std;\n\nint main() {\n cin.tie(nullptr),\ \ ios::sync_with_stdio(false);\n\n int N, X;\n cin >> N >> X;\n vector\ \ A(N);\n for (auto &x : A) { cin >> x; }\n const int D = 18;\n vector\n\ - using namespace std;\n#define FOR(i, begin, end) for (int i = (begin); i < (end);\ - \ i++)\n#define REP(i, n) FOR(i, 0, n)\n\nusing lint = long long;\nstruct node\ - \ {\n lint val, sum;\n node() : val(0), sum(0) {}\n node(lint v) : val(v),\ - \ sum(v) {}\n};\n\nusing VAL = node;\nusing DVAL = lint;\ntemplate \ - \ struct RandomizedBinarySearchTree {\n // Do your RuBeSTy! \u2312\xB0( \u30FB\ - \u03C9\u30FB)\xB0\u2312\n /*\n struct rand_int_ // non-deterministic\n \ - \ {\n mt19937 mt;\n rand_int_() : mt(chrono::steady_clock::now().time_since_epoch().count())\ - \ {}\n lint operator()(lint x) { return this->operator()(0, x); } // [0,\ - \ x)\n lint operator()(lint l, lint r) {\n uniform_int_distribution\ - \ d(l, r - 1);\n return d(mt);\n }\n lint operator()()\ - \ { return this->operator()(1e8); }\n } _rand;\n /*/\n inline uint32_t\ - \ _rand() // XorShift\n {\n static uint32_t x = 123456789, y = 362436069,\ - \ z = 521288629, w = 88675123;\n uint32_t t = x ^ (x << 11);\n x\ - \ = y;\n y = z;\n z = w;\n return w = (w ^ (w >> 19)) ^ (t\ - \ ^ (t >> 8));\n }\n // */\n\n // \u5404\u30CE\u30FC\u30C9\u306B\u6301\ - \u305F\u305B\u308B\u30C7\u30FC\u30BF\u578B\u3068\u4EE3\u6570\u69CB\u9020\n \ - \ DVAL Idval;\n struct Node {\n Node *l, *r;\n uint32_t sz; //\ - \ \u81EA\u8EAB\u3092\u9802\u70B9\u3068\u3059\u308B\u90E8\u5206\u6728\u306E\u30B5\ - \u30A4\u30BA\n VAL val; // \u81EA\u8EAB\u304Croot\u306E\u90E8\u5206\u6728\ - \u3092\u8A18\u8FF0, dval==Idval\u306E\u3068\u304D\u306E\u307F\u5358\u72EC\u3067\ - \u610F\u5473\u3092\u6301\u3064\n DVAL dval; // \u81EA\u8EAB\u3068\u305D\ - \u306E\u90E8\u5206\u6728\u306B\u5BFE\u3059\u308B\u9045\u5EF6\u8A55\u4FA1\n \ - \ Node(const VAL &v, const DVAL &dv) : l(nullptr), r(nullptr), sz(1), val(v),\ - \ dval(dv) {}\n Node() {}\n };\n inline Node *_revise_val(Node *t)\ - \ // \uFF08t\u306E\u5B50\u306B\u95A2\u3059\u308B\u5916\u7684\u64CD\u4F5C\u5F8C\ - \u306B\u547C\u3093\u3067\uFF09sz\u3068val\u3092\u9069\u5207\u306B\u76F4\u3059\n\ - \ // t\u306E\u5B50\u306E\u9045\u5EF6\u8A55\ - \u4FA1\u304C\u6E08\u3093\u3067\u3044\u308B\u3068\u306F\u9650\u3089\u306A\u3044\ - \n {\n if (t) {\n t->sz = size(t->l) + size(t->r) + 1;\n\ - \ t->val.sum = t->val.val + (t->l ? t->l->val.sum + t->l->sz * t->l->dval\ - \ : 0) +\n (t->r ? t->r->val.sum + t->r->sz * t->r->dval\ - \ : 0);\n };\n return t;\n }\n inline void _propagate_dval(DVAL\ - \ &a, DVAL b) // \u9045\u5EF6\u8A55\u4FA1\u4F1D\u64AD\n {\n a += b;\n\ - \ }\n inline void _reflect_dval(Node *a, DVAL b) // \u9045\u5EF6\u8A55\u4FA1\ - \u53CD\u6620\n {\n a->val.val += b;\n a->val.sum += a->sz * b;\n\ - \ }\n vector data;\n uint32_t d_ptr;\n\n RandomizedBinarySearchTree(DVAL\ - \ idval) : Idval(idval), d_ptr(0) { data.resize(len); }\n\n Node *new_tree()\ - \ { return nullptr; } // \u65B0\u305F\u306A\u6728\u3092\u4F5C\u6210\n static\ - \ inline uint32_t size(const Node *t) { return t ? t->sz : 0; }\n inline int\ - \ mem_used() { return (int)d_ptr; }\n inline bool empty(Node *t) { return !t;\ - \ }\n inline Node *_make_node(const VAL &val) {\n if (d_ptr >= len)\ - \ exit(1);\n return &(data[d_ptr++] = Node(val, Idval));\n }\n virtual\ - \ void _duplicate_node(Node *&) {}\n\n inline void _resolve_dval(Node *&t)\ - \ // \u5BFE\u8C61\u306E\u9045\u5EF6\u8A55\u4FA1\u3092\u89E3\u6C7A\n {\n \ - \ if (!t) return;\n _duplicate_node(t);\n if (t->dval != Idval)\ - \ {\n if (t->l) {\n _duplicate_node(t->l);\n \ - \ _propagate_dval(t->l->dval, t->dval);\n }\n if\ - \ (t->r) {\n _duplicate_node(t->r);\n _propagate_dval(t->r->dval,\ - \ t->dval);\n }\n _reflect_dval(t, t->dval);\n \ - \ t->dval = Idval;\n }\n }\n\n // l\u3068r\u3092root\u3068\u3059\ - \u308B\u6728\u540C\u58EB\u3092\u7D50\u5408\u3057\u3066\uFF0C\u65B0\u305F\u306A\ - root\u3092\u8FD4\u3059\n Node *merge(Node *l, Node *r) {\n if (l ==\ - \ nullptr || r == nullptr) return l ? l : r;\n if (_rand() % (l->sz + r->sz)\ - \ < l->sz) {\n _resolve_dval(l);\n l->r = merge(l->r, r);\n\ - \ return _revise_val(l);\n } else {\n _resolve_dval(r);\n\ - \ r->l = merge(l, r->l);\n return _revise_val(r);\n \ - \ }\n }\n\n // [0, k)\u306E\u6728\u3068[k, root->size())\u306E\u6728\u306B\ - \u5206\u3051\u3066\u5404root\n // \uFF08\u90E8\u5206\u6728\u306E\u8981\u7D20\ - \u6570\u304C0\u306A\u3089nullptr\uFF09\u3092\u8FD4\u3059\n pair split(Node *&root, int k) // root\u306E\u5B50\u5B6B\u304B\u3089\u3042\u3068\ - k\u500B\u6B32\u3057\u3044\n {\n if (root == nullptr) return make_pair(nullptr,\ - \ nullptr);\n _resolve_dval(root);\n if (k <= (int)size(root->l))\ - \ // left\u304B\u3089k\u500B\u62FE\u3048\u308B\n {\n auto p\ - \ = split(root->l, k);\n root->l = p.second;\n return make_pair(p.first,\ - \ _revise_val(root));\n } else {\n auto p = split(root->r, k\ - \ - size(root->l) - 1);\n root->r = p.first;\n return make_pair(_revise_val(root),\ - \ p.second);\n }\n }\n\n // 0-indexed\u3067array[pos]\u306E\u624B\ - \u524D\u306B\u65B0\u305F\u306A\u8981\u7D20newval\u3092\u633F\u5165\u3059\u308B\ - \n void insert(Node *&root, int pos, const VAL &newval) {\n auto p =\ - \ split(root, pos);\n root = merge(p.first, merge(_make_node(newval), p.second));\n\ - \ }\n\n // 0-indexed\u3067array[pos]\u3092\u524A\u9664\u3059\u308B\uFF08\ - \u5148\u982D\u304B\u3089pos+1\u500B\u76EE\u306E\u8981\u7D20\uFF09\n void erase(Node\ - \ *&root, int pos) {\n auto p = split(root, pos);\n auto p2 = split(p.second,\ - \ 1);\n root = merge(p.first, p2.second);\n }\n\n // 1\u70B9\u66F4\ - \u65B0 array[pos].val\u306Bupdval\u3092\u5165\u308C\u308B\n void set(Node *&root,\ - \ int pos, const VAL &updval) {\n auto p = split(root, pos);\n auto\ - \ p2 = split(p.second, 1);\n root = merge(p.first, merge(_make_node(updval),\ - \ p2.second));\n }\n\n // \u9045\u5EF6\u8A55\u4FA1\u3092\u5229\u7528\u3057\ - \u305F\u7BC4\u56F2\u66F4\u65B0 [l, r)\n void range_set(Node *&root, int l,\ - \ int r, const DVAL &adddval) {\n auto p = split(root, l);\n auto\ - \ p2 = split(p.second, r - l);\n _propagate_dval(p2.first->dval, adddval);\n\ - \ root = merge(p.first, merge(p2.first, p2.second));\n }\n\n // array[pos].val\u3092\ - \u53D6\u5F97\u3059\u308B\n Node range_get(Node *&root, int l, int r) {\n \ - \ auto p = split(root, l);\n auto p2 = split(p.second, r - l);\n \ - \ _resolve_dval(p2.first);\n Node res = *p2.first;\n root\ - \ = merge(p.first, merge(p2.first, p2.second));\n return res;\n }\n\ - \ Node get(Node *&root, int pos) { return range_get(root, pos, pos + 1); }\n\ - \n // \u666E\u901A\u306Elower_bound\n int lower_bound(Node *root, const\ - \ VAL &v) {\n if (root == nullptr) return 0;\n return (v <= root->val)\ - \ ? lower_bound(root->l, v)\n : lower_bound(root->r,\ - \ v) + size(root->l) + 1;\n }\n\n // \u30C7\u30FC\u30BF\u3092\u58CA\u3057\ - \u3066\u65B0\u898F\u306Binit\u306E\u5185\u5BB9\u3092\u8A70\u3081\u308B\n void\ - \ assign(Node *&root, const vector &init) {\n d_ptr = 0;\n \ - \ int N = init.size();\n root = N ? _assign_range(0, N, init) : new_tree();\n\ - \ }\n Node *_assign_range(int l, int r, const vector &init) {\n \ - \ if (r - l == 1) {\n auto t = _make_node(init[l]);\n \ - \ return _revise_val(t);\n }\n return merge(_assign_range(l, (l\ - \ + r) / 2, init), _assign_range((l + r) / 2, r, init));\n }\n\n // \u30C7\ - \u30FC\u30BF\u3092vec\u3078\u66F8\u304D\u51FA\u3057\n void dump(Node *t, vector\ - \ &vec) {\n if (t == nullptr) return;\n _resolve_dval(t);\n \ - \ dump(t->l, vec);\n vec.push_back(t->val);\n dump(t->r, vec);\n\ - \ }\n\n // gc\n void re_alloc(Node *&root) {\n vector mem;\n\ - \ dump(root, mem);\n assign(root, mem);\n }\n};\n\n// \u6C38\u7D9A\ - \u5316\ntemplate struct PersistentRBST : RandomizedBinarySearchTree\ - \ {\n using RBST = RandomizedBinarySearchTree;\n using Node = typename\ - \ RBST::Node;\n PersistentRBST(DVAL idval) : RBST(idval) {}\n\n void _duplicate_node(Node\ - \ *&t) override {\n if (t == nullptr) return;\n if (RBST::d_ptr\ - \ >= len) exit(1);\n t = &(RBST::data[RBST::d_ptr++] = *t);\n }\n\n\ - \ void copy(Node *&root, int l, int d, int target_l) // [target_l, )\u306B\ - [l, l+d)\u306E\u5024\u3092\u5165\u308C\u308B\n {\n auto p1 = RBST::split(root,\ - \ l);\n auto p2 = RBST::split(p1.second, d);\n root = RBST::merge(p1.first,\ - \ RBST::merge(p2.first, p2.second));\n auto p3 = RBST::split(root, target_l);\n\ - \ auto p4 = RBST::split(p3.second, d);\n root = RBST::merge(p3.first,\ - \ RBST::merge(p2.first, p4.second));\n }\n};\n\nint main() {\n constexpr\ - \ int mem_size = 13000000;\n PersistentRBST rbst(0LL);\n\n auto\ - \ S = rbst.new_tree();\n int N, Q;\n cin >> N >> Q;\n REP(i, N) {\n \ - \ int xi;\n cin >> xi;\n rbst.insert(S, i, node(xi));\n \ - \ }\n\n REP(_, Q) {\n int type, a, b, c, d, v;\n cin >> type;\n\ - \ if (type == 1) {\n cin >> a >> b >> v;\n rbst.range_set(S,\ - \ a - 1, b, (lint)v);\n }\n if (type == 2) {\n cin >>\ - \ a >> b >> c >> d;\n rbst.copy(S, c - 1, b - a + 1, a - 1);\n \ - \ }\n if (type == 3) {\n cin >> a >> b;\n cout\ - \ << rbst.range_get(S, a - 1, b).val.sum << endl;\n }\n if (rbst.mem_used()\ - \ > mem_size * 0.8) rbst.re_alloc(S);\n }\n}\n" - code: "// Persistent Randomized Binary Search Tree\n// Verified : ARC033C\u30FB\ - ARC030D\n\n#include \nusing namespace std;\n#define FOR(i, begin,\ - \ end) for (int i = (begin); i < (end); i++)\n#define REP(i, n) FOR(i, 0, n)\n\ - \nusing lint = long long;\nstruct node {\n lint val, sum;\n node() : val(0),\ - \ sum(0) {}\n node(lint v) : val(v), sum(v) {}\n};\n\nusing VAL = node;\nusing\ - \ DVAL = lint;\ntemplate struct RandomizedBinarySearchTree {\n\ - \ // Do your RuBeSTy! \u2312\xB0( \u30FB\u03C9\u30FB)\xB0\u2312\n /*\n \ - \ struct rand_int_ // non-deterministic\n {\n mt19937 mt;\n \ - \ rand_int_() : mt(chrono::steady_clock::now().time_since_epoch().count()) {}\n\ - \ lint operator()(lint x) { return this->operator()(0, x); } // [0, x)\n\ - \ lint operator()(lint l, lint r) {\n uniform_int_distribution\ - \ d(l, r - 1);\n return d(mt);\n }\n lint operator()()\ - \ { return this->operator()(1e8); }\n } _rand;\n /*/\n inline uint32_t\ - \ _rand() // XorShift\n {\n static uint32_t x = 123456789, y = 362436069,\ - \ z = 521288629, w = 88675123;\n uint32_t t = x ^ (x << 11);\n x\ - \ = y;\n y = z;\n z = w;\n return w = (w ^ (w >> 19)) ^ (t\ - \ ^ (t >> 8));\n }\n // */\n\n // \u5404\u30CE\u30FC\u30C9\u306B\u6301\ - \u305F\u305B\u308B\u30C7\u30FC\u30BF\u578B\u3068\u4EE3\u6570\u69CB\u9020\n \ - \ DVAL Idval;\n struct Node {\n Node *l, *r;\n uint32_t sz; //\ - \ \u81EA\u8EAB\u3092\u9802\u70B9\u3068\u3059\u308B\u90E8\u5206\u6728\u306E\u30B5\ - \u30A4\u30BA\n VAL val; // \u81EA\u8EAB\u304Croot\u306E\u90E8\u5206\u6728\ - \u3092\u8A18\u8FF0, dval==Idval\u306E\u3068\u304D\u306E\u307F\u5358\u72EC\u3067\ - \u610F\u5473\u3092\u6301\u3064\n DVAL dval; // \u81EA\u8EAB\u3068\u305D\ - \u306E\u90E8\u5206\u6728\u306B\u5BFE\u3059\u308B\u9045\u5EF6\u8A55\u4FA1\n \ - \ Node(const VAL &v, const DVAL &dv) : l(nullptr), r(nullptr), sz(1), val(v),\ - \ dval(dv) {}\n Node() {}\n };\n inline Node *_revise_val(Node *t)\ - \ // \uFF08t\u306E\u5B50\u306B\u95A2\u3059\u308B\u5916\u7684\u64CD\u4F5C\u5F8C\ - \u306B\u547C\u3093\u3067\uFF09sz\u3068val\u3092\u9069\u5207\u306B\u76F4\u3059\n\ - \ // t\u306E\u5B50\u306E\u9045\u5EF6\u8A55\ - \u4FA1\u304C\u6E08\u3093\u3067\u3044\u308B\u3068\u306F\u9650\u3089\u306A\u3044\ - \n {\n if (t) {\n t->sz = size(t->l) + size(t->r) + 1;\n\ - \ t->val.sum = t->val.val + (t->l ? t->l->val.sum + t->l->sz * t->l->dval\ - \ : 0) +\n (t->r ? t->r->val.sum + t->r->sz * t->r->dval\ - \ : 0);\n };\n return t;\n }\n inline void _propagate_dval(DVAL\ - \ &a, DVAL b) // \u9045\u5EF6\u8A55\u4FA1\u4F1D\u64AD\n {\n a += b;\n\ - \ }\n inline void _reflect_dval(Node *a, DVAL b) // \u9045\u5EF6\u8A55\u4FA1\ - \u53CD\u6620\n {\n a->val.val += b;\n a->val.sum += a->sz * b;\n\ - \ }\n vector data;\n uint32_t d_ptr;\n\n RandomizedBinarySearchTree(DVAL\ - \ idval) : Idval(idval), d_ptr(0) { data.resize(len); }\n\n Node *new_tree()\ - \ { return nullptr; } // \u65B0\u305F\u306A\u6728\u3092\u4F5C\u6210\n static\ - \ inline uint32_t size(const Node *t) { return t ? t->sz : 0; }\n inline int\ - \ mem_used() { return (int)d_ptr; }\n inline bool empty(Node *t) { return !t;\ - \ }\n inline Node *_make_node(const VAL &val) {\n if (d_ptr >= len)\ - \ exit(1);\n return &(data[d_ptr++] = Node(val, Idval));\n }\n virtual\ - \ void _duplicate_node(Node *&) {}\n\n inline void _resolve_dval(Node *&t)\ - \ // \u5BFE\u8C61\u306E\u9045\u5EF6\u8A55\u4FA1\u3092\u89E3\u6C7A\n {\n \ - \ if (!t) return;\n _duplicate_node(t);\n if (t->dval != Idval)\ - \ {\n if (t->l) {\n _duplicate_node(t->l);\n \ - \ _propagate_dval(t->l->dval, t->dval);\n }\n if\ - \ (t->r) {\n _duplicate_node(t->r);\n _propagate_dval(t->r->dval,\ - \ t->dval);\n }\n _reflect_dval(t, t->dval);\n \ - \ t->dval = Idval;\n }\n }\n\n // l\u3068r\u3092root\u3068\u3059\ - \u308B\u6728\u540C\u58EB\u3092\u7D50\u5408\u3057\u3066\uFF0C\u65B0\u305F\u306A\ - root\u3092\u8FD4\u3059\n Node *merge(Node *l, Node *r) {\n if (l ==\ - \ nullptr || r == nullptr) return l ? l : r;\n if (_rand() % (l->sz + r->sz)\ - \ < l->sz) {\n _resolve_dval(l);\n l->r = merge(l->r, r);\n\ - \ return _revise_val(l);\n } else {\n _resolve_dval(r);\n\ - \ r->l = merge(l, r->l);\n return _revise_val(r);\n \ - \ }\n }\n\n // [0, k)\u306E\u6728\u3068[k, root->size())\u306E\u6728\u306B\ - \u5206\u3051\u3066\u5404root\n // \uFF08\u90E8\u5206\u6728\u306E\u8981\u7D20\ - \u6570\u304C0\u306A\u3089nullptr\uFF09\u3092\u8FD4\u3059\n pair split(Node *&root, int k) // root\u306E\u5B50\u5B6B\u304B\u3089\u3042\u3068\ - k\u500B\u6B32\u3057\u3044\n {\n if (root == nullptr) return make_pair(nullptr,\ - \ nullptr);\n _resolve_dval(root);\n if (k <= (int)size(root->l))\ - \ // left\u304B\u3089k\u500B\u62FE\u3048\u308B\n {\n auto p\ - \ = split(root->l, k);\n root->l = p.second;\n return make_pair(p.first,\ - \ _revise_val(root));\n } else {\n auto p = split(root->r, k\ - \ - size(root->l) - 1);\n root->r = p.first;\n return make_pair(_revise_val(root),\ - \ p.second);\n }\n }\n\n // 0-indexed\u3067array[pos]\u306E\u624B\ - \u524D\u306B\u65B0\u305F\u306A\u8981\u7D20newval\u3092\u633F\u5165\u3059\u308B\ - \n void insert(Node *&root, int pos, const VAL &newval) {\n auto p =\ - \ split(root, pos);\n root = merge(p.first, merge(_make_node(newval), p.second));\n\ - \ }\n\n // 0-indexed\u3067array[pos]\u3092\u524A\u9664\u3059\u308B\uFF08\ - \u5148\u982D\u304B\u3089pos+1\u500B\u76EE\u306E\u8981\u7D20\uFF09\n void erase(Node\ - \ *&root, int pos) {\n auto p = split(root, pos);\n auto p2 = split(p.second,\ - \ 1);\n root = merge(p.first, p2.second);\n }\n\n // 1\u70B9\u66F4\ - \u65B0 array[pos].val\u306Bupdval\u3092\u5165\u308C\u308B\n void set(Node *&root,\ - \ int pos, const VAL &updval) {\n auto p = split(root, pos);\n auto\ - \ p2 = split(p.second, 1);\n root = merge(p.first, merge(_make_node(updval),\ - \ p2.second));\n }\n\n // \u9045\u5EF6\u8A55\u4FA1\u3092\u5229\u7528\u3057\ - \u305F\u7BC4\u56F2\u66F4\u65B0 [l, r)\n void range_set(Node *&root, int l,\ - \ int r, const DVAL &adddval) {\n auto p = split(root, l);\n auto\ - \ p2 = split(p.second, r - l);\n _propagate_dval(p2.first->dval, adddval);\n\ - \ root = merge(p.first, merge(p2.first, p2.second));\n }\n\n // array[pos].val\u3092\ - \u53D6\u5F97\u3059\u308B\n Node range_get(Node *&root, int l, int r) {\n \ - \ auto p = split(root, l);\n auto p2 = split(p.second, r - l);\n \ - \ _resolve_dval(p2.first);\n Node res = *p2.first;\n root\ - \ = merge(p.first, merge(p2.first, p2.second));\n return res;\n }\n\ - \ Node get(Node *&root, int pos) { return range_get(root, pos, pos + 1); }\n\ - \n // \u666E\u901A\u306Elower_bound\n int lower_bound(Node *root, const\ - \ VAL &v) {\n if (root == nullptr) return 0;\n return (v <= root->val)\ - \ ? lower_bound(root->l, v)\n : lower_bound(root->r,\ - \ v) + size(root->l) + 1;\n }\n\n // \u30C7\u30FC\u30BF\u3092\u58CA\u3057\ - \u3066\u65B0\u898F\u306Binit\u306E\u5185\u5BB9\u3092\u8A70\u3081\u308B\n void\ - \ assign(Node *&root, const vector &init) {\n d_ptr = 0;\n \ - \ int N = init.size();\n root = N ? _assign_range(0, N, init) : new_tree();\n\ - \ }\n Node *_assign_range(int l, int r, const vector &init) {\n \ - \ if (r - l == 1) {\n auto t = _make_node(init[l]);\n \ - \ return _revise_val(t);\n }\n return merge(_assign_range(l, (l\ - \ + r) / 2, init), _assign_range((l + r) / 2, r, init));\n }\n\n // \u30C7\ - \u30FC\u30BF\u3092vec\u3078\u66F8\u304D\u51FA\u3057\n void dump(Node *t, vector\ - \ &vec) {\n if (t == nullptr) return;\n _resolve_dval(t);\n \ - \ dump(t->l, vec);\n vec.push_back(t->val);\n dump(t->r, vec);\n\ - \ }\n\n // gc\n void re_alloc(Node *&root) {\n vector mem;\n\ - \ dump(root, mem);\n assign(root, mem);\n }\n};\n\n// \u6C38\u7D9A\ - \u5316\ntemplate struct PersistentRBST : RandomizedBinarySearchTree\ - \ {\n using RBST = RandomizedBinarySearchTree;\n using Node = typename\ - \ RBST::Node;\n PersistentRBST(DVAL idval) : RBST(idval) {}\n\n void _duplicate_node(Node\ - \ *&t) override {\n if (t == nullptr) return;\n if (RBST::d_ptr\ - \ >= len) exit(1);\n t = &(RBST::data[RBST::d_ptr++] = *t);\n }\n\n\ - \ void copy(Node *&root, int l, int d, int target_l) // [target_l, )\u306B\ - [l, l+d)\u306E\u5024\u3092\u5165\u308C\u308B\n {\n auto p1 = RBST::split(root,\ - \ l);\n auto p2 = RBST::split(p1.second, d);\n root = RBST::merge(p1.first,\ - \ RBST::merge(p2.first, p2.second));\n auto p3 = RBST::split(root, target_l);\n\ - \ auto p4 = RBST::split(p3.second, d);\n root = RBST::merge(p3.first,\ - \ RBST::merge(p2.first, p4.second));\n }\n};\n\nint main() {\n constexpr\ - \ int mem_size = 13000000;\n PersistentRBST rbst(0LL);\n\n auto\ - \ S = rbst.new_tree();\n int N, Q;\n cin >> N >> Q;\n REP(i, N) {\n \ - \ int xi;\n cin >> xi;\n rbst.insert(S, i, node(xi));\n \ - \ }\n\n REP(_, Q) {\n int type, a, b, c, d, v;\n cin >> type;\n\ - \ if (type == 1) {\n cin >> a >> b >> v;\n rbst.range_set(S,\ - \ a - 1, b, (lint)v);\n }\n if (type == 2) {\n cin >>\ - \ a >> b >> c >> d;\n rbst.copy(S, c - 1, b - a + 1, a - 1);\n \ - \ }\n if (type == 3) {\n cin >> a >> b;\n cout\ - \ << rbst.range_get(S, a - 1, b).val.sum << endl;\n }\n if (rbst.mem_used()\ - \ > mem_size * 0.8) rbst.re_alloc(S);\n }\n}\n" - dependsOn: [] - isVerificationFile: false - path: data_structure/rbst_fast.cpp - requiredBy: [] - timestamp: '2022-01-08 20:23:44+09:00' - verificationStatus: LIBRARY_NO_TESTS - verifiedWith: [] -documentation_of: data_structure/rbst_fast.cpp -layout: document -redirect_from: -- /library/data_structure/rbst_fast.cpp -- /library/data_structure/rbst_fast.cpp.html -title: data_structure/rbst_fast.cpp ---- diff --git a/flow/networksimplex.hpp.md b/flow/networksimplex.hpp.md index a2da5d24..ce7543b7 100644 --- a/flow/networksimplex.hpp.md +++ b/flow/networksimplex.hpp.md @@ -606,7 +606,7 @@ data: \ typename Weight = long long> struct mcf_graph_ns {\n\n struct Digraph {\n\ \ const int V;\n int E;\n std::vector> in_eids,\ \ out_eids;\n std::vector> arcs;\n Digraph(int\ - \ V = 0) : V(V), E(0), in_eids(V), out_eids(V){};\n int add_edge(int s,\ + \ V = 0) : V(V), E(0), in_eids(V), out_eids(V) {};\n int add_edge(int s,\ \ int t) {\n assert(0 <= s and s < V);\n assert(0 <= t and\ \ t < V);\n in_eids[t].push_back(E), out_eids[s].push_back(E), arcs.emplace_back(s,\ \ t), E++;\n return E - 1;\n }\n int countNodes() const\ @@ -1232,7 +1232,7 @@ data: \ typename Weight = long long> struct mcf_graph_ns {\n\n struct Digraph {\n\ \ const int V;\n int E;\n std::vector> in_eids,\ \ out_eids;\n std::vector> arcs;\n Digraph(int\ - \ V = 0) : V(V), E(0), in_eids(V), out_eids(V){};\n int add_edge(int s,\ + \ V = 0) : V(V), E(0), in_eids(V), out_eids(V) {};\n int add_edge(int s,\ \ int t) {\n assert(0 <= s and s < V);\n assert(0 <= t and\ \ t < V);\n in_eids[t].push_back(E), out_eids[s].push_back(E), arcs.emplace_back(s,\ \ t), E++;\n return E - 1;\n }\n int countNodes() const\ @@ -1272,7 +1272,7 @@ data: isVerificationFile: false path: flow/networksimplex.hpp requiredBy: [] - timestamp: '2022-12-07 23:52:43+09:00' + timestamp: '2024-09-22 15:59:27+09:00' verificationStatus: LIBRARY_ALL_AC verifiedWith: - flow/test/bflow_ns.test.cpp diff --git a/flow/test/bflow_ns.test.cpp.md b/flow/test/bflow_ns.test.cpp.md index e412a355..c65990d0 100644 --- a/flow/test/bflow_ns.test.cpp.md +++ b/flow/test/bflow_ns.test.cpp.md @@ -606,7 +606,7 @@ data: \ typename Weight = long long> struct mcf_graph_ns {\n\n struct Digraph {\n\ \ const int V;\n int E;\n std::vector> in_eids,\ \ out_eids;\n std::vector> arcs;\n Digraph(int\ - \ V = 0) : V(V), E(0), in_eids(V), out_eids(V){};\n int add_edge(int s,\ + \ V = 0) : V(V), E(0), in_eids(V), out_eids(V) {};\n int add_edge(int s,\ \ int t) {\n assert(0 <= s and s < V);\n assert(0 <= t and\ \ t < V);\n in_eids[t].push_back(E), out_eids[s].push_back(E), arcs.emplace_back(s,\ \ t), E++;\n return E - 1;\n }\n int countNodes() const\ @@ -681,7 +681,7 @@ data: isVerificationFile: true path: flow/test/bflow_ns.test.cpp requiredBy: [] - timestamp: '2022-12-07 23:52:43+09:00' + timestamp: '2024-09-22 15:59:27+09:00' verificationStatus: TEST_ACCEPTED verifiedWith: [] documentation_of: flow/test/bflow_ns.test.cpp diff --git a/flow/test/mcf_ns.test.cpp.md b/flow/test/mcf_ns.test.cpp.md index 248905f5..b85a6a53 100644 --- a/flow/test/mcf_ns.test.cpp.md +++ b/flow/test/mcf_ns.test.cpp.md @@ -607,7 +607,7 @@ data: \ typename Weight = long long> struct mcf_graph_ns {\n\n struct Digraph {\n\ \ const int V;\n int E;\n std::vector> in_eids,\ \ out_eids;\n std::vector> arcs;\n Digraph(int\ - \ V = 0) : V(V), E(0), in_eids(V), out_eids(V){};\n int add_edge(int s,\ + \ V = 0) : V(V), E(0), in_eids(V), out_eids(V) {};\n int add_edge(int s,\ \ int t) {\n assert(0 <= s and s < V);\n assert(0 <= t and\ \ t < V);\n in_eids[t].push_back(E), out_eids[s].push_back(E), arcs.emplace_back(s,\ \ t), E++;\n return E - 1;\n }\n int countNodes() const\ @@ -660,7 +660,7 @@ data: isVerificationFile: true path: flow/test/mcf_ns.test.cpp requiredBy: [] - timestamp: '2022-12-07 23:52:43+09:00' + timestamp: '2024-09-22 15:59:27+09:00' verificationStatus: TEST_ACCEPTED verifiedWith: [] documentation_of: flow/test/mcf_ns.test.cpp diff --git a/index.md b/index.md index 36e72735..f16d5d46 100644 --- a/index.md +++ b/index.md @@ -156,9 +156,6 @@ data: - icon: ':heavy_check_mark:' path: data_structure/range_kth_smallest_offline.hpp title: data_structure/range_kth_smallest_offline.hpp - - icon: ':warning:' - path: data_structure/rbst_fast.cpp - title: data_structure/rbst_fast.cpp - icon: ':heavy_check_mark:' path: data_structure/rectangle_add_rectangle_sum.hpp title: "Static rectangle add rectangle sum \uFF08\u77E9\u5F62\u4E00\u69D8\u52A0\ diff --git a/multithread/multithread_example.cpp.md b/multithread/multithread_example.cpp.md index 098605bd..6b17a907 100644 --- a/multithread/multithread_example.cpp.md +++ b/multithread/multithread_example.cpp.md @@ -14,7 +14,7 @@ data: \u306B -pthread \u304C\u5FC5\u8981\n#include \nusing namespace\ \ std;\nusing pint = pair;\n#define FOR(i, begin, end) for (int i =\ \ (begin), i##_end_ = (end); i < i##_end_; i++)\n#define IFOR(i, begin, end) for\ - \ (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)\n#define REP(i,\ + \ (int i = (end) - 1, i##_begin_ = (begin); i >= i##_begin_; i--)\n#define REP(i,\ \ n) FOR(i, 0, n)\n#define IREP(i, n) IFOR(i, 0, n)\n#define dbg(x) cerr << #x\ \ << \" = \" << (x) << \" (L\" << __LINE__ << \") \" << __FILE__ << endl;\n\n\ struct SingleCaseInput {\n int N, M;\n vector query;\n SingleCaseInput(int\ @@ -22,7 +22,7 @@ data: \ testcase;\n\nvector ret;\n\n/* \u5404\u30C6\u30B9\u30C8\u30B1\u30FC\u30B9\ \u306E\u5B8C\u4E86\u72B6\u6CC1\u3092\u4FDD\u6301 */\nmutex mtx;\nvector done;\n\ \nvoid solve(int tc) { /* tc\u500B\u76EE\u306E\u30C6\u30B9\u30C8\u30B1\u30FC\u30B9\ - \u3092\u51E6\u7406\u3059\u308B\u95A2\u6570 */\n}\n\nvoid run() {\n /* \u672A\ + \u3092\u51E6\u7406\u3059\u308B\u95A2\u6570 */ }\n\nvoid run() {\n /* \u672A\ \u5B8C\u4E86\u3067\u6700\u3082\u756A\u53F7\u304C\u82E5\u3044\u30C6\u30B9\u30C8\ \u30B1\u30FC\u30B9\u3092\u51E6\u7406 */\n int i = 0;\n while (true) {\n\ \ mtx.lock();\n while (i < done.size() and done[i]) i++;\n \ @@ -45,7 +45,7 @@ data: \u30D7\u30B7\u30E7\u30F3\u306B -pthread \u304C\u5FC5\u8981\n#include \n\ using namespace std;\nusing pint = pair;\n#define FOR(i, begin, end)\ \ for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)\n#define IFOR(i,\ - \ begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)\n\ + \ begin, end) for (int i = (end) - 1, i##_begin_ = (begin); i >= i##_begin_; i--)\n\ #define REP(i, n) FOR(i, 0, n)\n#define IREP(i, n) IFOR(i, 0, n)\n#define dbg(x)\ \ cerr << #x << \" = \" << (x) << \" (L\" << __LINE__ << \") \" << __FILE__ <<\ \ endl;\n\nstruct SingleCaseInput {\n int N, M;\n vector query;\n\ @@ -54,7 +54,7 @@ data: \u30C6\u30B9\u30C8\u30B1\u30FC\u30B9\u306E\u5B8C\u4E86\u72B6\u6CC1\u3092\u4FDD\ \u6301 */\nmutex mtx;\nvector done;\n\nvoid solve(int tc) { /* tc\u500B\u76EE\ \u306E\u30C6\u30B9\u30C8\u30B1\u30FC\u30B9\u3092\u51E6\u7406\u3059\u308B\u95A2\ - \u6570 */\n}\n\nvoid run() {\n /* \u672A\u5B8C\u4E86\u3067\u6700\u3082\u756A\ + \u6570 */ }\n\nvoid run() {\n /* \u672A\u5B8C\u4E86\u3067\u6700\u3082\u756A\ \u53F7\u304C\u82E5\u3044\u30C6\u30B9\u30C8\u30B1\u30FC\u30B9\u3092\u51E6\u7406\ \ */\n int i = 0;\n while (true) {\n mtx.lock();\n while (i\ \ < done.size() and done[i]) i++;\n if (i < done.size()) done[i] = 1;\n\ @@ -75,7 +75,7 @@ data: isVerificationFile: false path: multithread/multithread_example.cpp requiredBy: [] - timestamp: '2022-01-08 20:23:44+09:00' + timestamp: '2024-09-22 15:59:27+09:00' verificationStatus: LIBRARY_NO_TESTS verifiedWith: [] documentation_of: multithread/multithread_example.cpp diff --git a/string/palindromic_tree.hpp.md b/string/palindromic_tree.hpp.md index 2d4140bd..105dac91 100644 --- a/string/palindromic_tree.hpp.md +++ b/string/palindromic_tree.hpp.md @@ -19,9 +19,9 @@ data: \u6728\uFF09\nnamespace palindromic_tree {\n\ntemplate class Node\ \ {\n int suffix_link_; // \u3053\u306E\u30CE\u30FC\u30C9\u304B\u3089\u306E\ suffix link \uFF08suffix \u306E\u6700\u9577\u56DE\u6587\uFF09\n int length_;\ - \ // \u3053\u306E\u30CE\u30FC\u30C9\u304C\u8868\u3059\u56DE\u6587\u306E\u9577\u3055\ - \u3002 -1 \u3068\u306A\u308B\u5834\u5408\u3082\u3042\u308B\u306E\u3067\u6CE8\u610F\ - \n std::map children;\n\npublic:\n explicit Node(int suffix_link,\ + \ // \u3053\u306E\u30CE\u30FC\u30C9\u304C\u8868\u3059\u56DE\u6587\u306E\u9577\ + \u3055\u3002 -1 \u3068\u306A\u308B\u5834\u5408\u3082\u3042\u308B\u306E\u3067\u6CE8\ + \u610F\n std::map children;\n\npublic:\n explicit Node(int suffix_link,\ \ int length) : suffix_link_(suffix_link), length_(length) {}\n\n int suffix_link()\ \ const { return suffix_link_; }\n\n int length() const { return length_; }\n\ \n int get_child(Key c) const {\n auto it = children.find(c);\n \ @@ -66,26 +66,26 @@ data: // Palindromic tree / Eertree \uFF08\u56DE\u6587\u6728\uFF09\nnamespace palindromic_tree\ \ {\n\ntemplate class Node {\n int suffix_link_; // \u3053\u306E\ \u30CE\u30FC\u30C9\u304B\u3089\u306Esuffix link \uFF08suffix \u306E\u6700\u9577\ - \u56DE\u6587\uFF09\n int length_; // \u3053\u306E\u30CE\u30FC\u30C9\u304C\u8868\ - \u3059\u56DE\u6587\u306E\u9577\u3055\u3002 -1 \u3068\u306A\u308B\u5834\u5408\u3082\ - \u3042\u308B\u306E\u3067\u6CE8\u610F\n std::map children;\n\npublic:\n\ - \ explicit Node(int suffix_link, int length) : suffix_link_(suffix_link), length_(length)\ - \ {}\n\n int suffix_link() const { return suffix_link_; }\n\n int length()\ - \ const { return length_; }\n\n int get_child(Key c) const {\n auto\ - \ it = children.find(c);\n return (it == children.end()) ? -1 : it->second;\n\ - \ }\n\n void set_child(int c, int nxt_idx) { children[c] = nxt_idx; }\n\n\ - \ template friend OStream &operator<<(OStream &os, const Node\ - \ &node) {\n os << \"Node(suffix_link=\" << node.suffix_link() << \", length=\"\ - \ << node.length()\n << \", children={\";\n for (const auto &[c,\ - \ nxt] : node.children) os << c << \"->\" << nxt << \", \";\n return os\ - \ << \"})\";\n }\n};\n\n// Palindromic tree\n// nodes[0] \u306F\u9577\u3055\ - \ -1, nodes[1] \u306F\u9577\u3055 1 \u306E\u30C0\u30DF\u30FC\u30CE\u30FC\u30C9\ - \ntemplate struct Tree {\n std::vector> nodes;\n\n \ - \ Tree() { nodes = {Node(-1, -1), Node(0, 0)}; }\n\n // nodes[cursor]\ - \ \u306F s[0:i] \u306E suffix palindrome \u3092\u8868\u3059\n // \u672C\u95A2\ - \u6570\u306F\u305D\u306E nodes[cursor] \u306E suffix palindrome \u3067\u3042\u3063\ - \u3066\u66F4\u306B s[0:(i + 1)] \u306E suffix link \u3068\u306A\u308A\u3046\u308B\ - \u6700\u9577\u306E\u3082\u306E\u3092\u8FD4\u3059\n int find_next_suffix(const\ + \u56DE\u6587\uFF09\n int length_; // \u3053\u306E\u30CE\u30FC\u30C9\u304C\ + \u8868\u3059\u56DE\u6587\u306E\u9577\u3055\u3002 -1 \u3068\u306A\u308B\u5834\u5408\ + \u3082\u3042\u308B\u306E\u3067\u6CE8\u610F\n std::map children;\n\ + \npublic:\n explicit Node(int suffix_link, int length) : suffix_link_(suffix_link),\ + \ length_(length) {}\n\n int suffix_link() const { return suffix_link_; }\n\ + \n int length() const { return length_; }\n\n int get_child(Key c) const\ + \ {\n auto it = children.find(c);\n return (it == children.end())\ + \ ? -1 : it->second;\n }\n\n void set_child(int c, int nxt_idx) { children[c]\ + \ = nxt_idx; }\n\n template friend OStream &operator<<(OStream\ + \ &os, const Node &node) {\n os << \"Node(suffix_link=\" << node.suffix_link()\ + \ << \", length=\" << node.length()\n << \", children={\";\n \ + \ for (const auto &[c, nxt] : node.children) os << c << \"->\" << nxt << \", \"\ + ;\n return os << \"})\";\n }\n};\n\n// Palindromic tree\n// nodes[0]\ + \ \u306F\u9577\u3055 -1, nodes[1] \u306F\u9577\u3055 1 \u306E\u30C0\u30DF\u30FC\ + \u30CE\u30FC\u30C9\ntemplate struct Tree {\n std::vector>\ + \ nodes;\n\n Tree() { nodes = {Node(-1, -1), Node(0, 0)}; }\n\n \ + \ // nodes[cursor] \u306F s[0:i] \u306E suffix palindrome \u3092\u8868\u3059\ + \n // \u672C\u95A2\u6570\u306F\u305D\u306E nodes[cursor] \u306E suffix palindrome\ + \ \u3067\u3042\u3063\u3066\u66F4\u306B s[0:(i + 1)] \u306E suffix link \u3068\u306A\ + \u308A\u3046\u308B\u6700\u9577\u306E\u3082\u306E\u3092\u8FD4\u3059\n int find_next_suffix(const\ \ std::vector &s, int i, int cursor) {\n while (true) {\n \ \ if (cursor < 0) return 0;\n\n const int cur_len = nodes.at(cursor).length();\n\ \ const int opposite_pos = i - cur_len - 1;\n if (opposite_pos\ @@ -114,7 +114,7 @@ data: isVerificationFile: false path: string/palindromic_tree.hpp requiredBy: [] - timestamp: '2024-05-03 18:26:06+09:00' + timestamp: '2024-09-22 15:59:27+09:00' verificationStatus: LIBRARY_ALL_AC verifiedWith: - string/test/palindromic_tree.yuki2606.test.cpp diff --git a/string/test/palindromic_tree.yuki2606.test.cpp.md b/string/test/palindromic_tree.yuki2606.test.cpp.md index 2420e1e3..d639fd8d 100644 --- a/string/test/palindromic_tree.yuki2606.test.cpp.md +++ b/string/test/palindromic_tree.yuki2606.test.cpp.md @@ -20,9 +20,9 @@ data: \ / Eertree \uFF08\u56DE\u6587\u6728\uFF09\nnamespace palindromic_tree {\n\ntemplate\ \ class Node {\n int suffix_link_; // \u3053\u306E\u30CE\u30FC\u30C9\ \u304B\u3089\u306Esuffix link \uFF08suffix \u306E\u6700\u9577\u56DE\u6587\uFF09\ - \n int length_; // \u3053\u306E\u30CE\u30FC\u30C9\u304C\u8868\u3059\u56DE\u6587\ - \u306E\u9577\u3055\u3002 -1 \u3068\u306A\u308B\u5834\u5408\u3082\u3042\u308B\u306E\ - \u3067\u6CE8\u610F\n std::map children;\n\npublic:\n explicit\ + \n int length_; // \u3053\u306E\u30CE\u30FC\u30C9\u304C\u8868\u3059\u56DE\ + \u6587\u306E\u9577\u3055\u3002 -1 \u3068\u306A\u308B\u5834\u5408\u3082\u3042\u308B\ + \u306E\u3067\u6CE8\u610F\n std::map children;\n\npublic:\n explicit\ \ Node(int suffix_link, int length) : suffix_link_(suffix_link), length_(length)\ \ {}\n\n int suffix_link() const { return suffix_link_; }\n\n int length()\ \ const { return length_; }\n\n int get_child(Key c) const {\n auto\ @@ -95,7 +95,7 @@ data: isVerificationFile: true path: string/test/palindromic_tree.yuki2606.test.cpp requiredBy: [] - timestamp: '2024-05-03 18:26:06+09:00' + timestamp: '2024-09-22 15:59:27+09:00' verificationStatus: TEST_ACCEPTED verifiedWith: [] documentation_of: string/test/palindromic_tree.yuki2606.test.cpp diff --git a/string/test/palindromic_tree.yuki263.test.cpp.md b/string/test/palindromic_tree.yuki263.test.cpp.md index e55510e6..99a0ced9 100644 --- a/string/test/palindromic_tree.yuki263.test.cpp.md +++ b/string/test/palindromic_tree.yuki263.test.cpp.md @@ -20,9 +20,9 @@ data: \ / Eertree \uFF08\u56DE\u6587\u6728\uFF09\nnamespace palindromic_tree {\n\ntemplate\ \ class Node {\n int suffix_link_; // \u3053\u306E\u30CE\u30FC\u30C9\ \u304B\u3089\u306Esuffix link \uFF08suffix \u306E\u6700\u9577\u56DE\u6587\uFF09\ - \n int length_; // \u3053\u306E\u30CE\u30FC\u30C9\u304C\u8868\u3059\u56DE\u6587\ - \u306E\u9577\u3055\u3002 -1 \u3068\u306A\u308B\u5834\u5408\u3082\u3042\u308B\u306E\ - \u3067\u6CE8\u610F\n std::map children;\n\npublic:\n explicit\ + \n int length_; // \u3053\u306E\u30CE\u30FC\u30C9\u304C\u8868\u3059\u56DE\ + \u6587\u306E\u9577\u3055\u3002 -1 \u3068\u306A\u308B\u5834\u5408\u3082\u3042\u308B\ + \u306E\u3067\u6CE8\u610F\n std::map children;\n\npublic:\n explicit\ \ Node(int suffix_link, int length) : suffix_link_(suffix_link), length_(length)\ \ {}\n\n int suffix_link() const { return suffix_link_; }\n\n int length()\ \ const { return length_; }\n\n int get_child(Key c) const {\n auto\ @@ -95,7 +95,7 @@ data: isVerificationFile: true path: string/test/palindromic_tree.yuki263.test.cpp requiredBy: [] - timestamp: '2024-05-03 18:26:06+09:00' + timestamp: '2024-09-22 15:59:27+09:00' verificationStatus: TEST_ACCEPTED verifiedWith: [] documentation_of: string/test/palindromic_tree.yuki263.test.cpp diff --git a/tree/test/frequency_table_of_tree_distance.test.cpp.md b/tree/test/frequency_table_of_tree_distance.test.cpp.md index aebfb1f5..9ee692db 100644 --- a/tree/test/frequency_table_of_tree_distance.test.cpp.md +++ b/tree/test/frequency_table_of_tree_distance.test.cpp.md @@ -94,23 +94,22 @@ data: \ i = 0; i < vv[j - 1].size(); i++) vv[j][i] += vv[j - 1][i];\n }\n\ \ tos[root].clear();\n }\n return ret;\n }\n};\n#line\ \ 2 \"convolution/fft_double.hpp\"\n#include \n#line 5 \"convolution/fft_double.hpp\"\ - \n\n// CUT begin\n// Convolution by FFT (Fast Fourier Transform)\n// Algorithm\ - \ based on http://kirika-comp.hatenablog.com/entry/2018/03/12/210446\n// Verified:\ - \ ATC001C (168 ms) https://atcoder.jp/contests/atc001/submissions/9243440\nusing\ - \ cmplx = std::complex;\nvoid fft(int N, std::vector &a, double\ + \n\n// Convolution by FFT (Fast Fourier Transform)\n// Algorithm based on http://kirika-comp.hatenablog.com/entry/2018/03/12/210446\n\ + // Verified: ATC001C (168 ms) https://atcoder.jp/contests/atc001/submissions/9243440\n\ + using cmplx = std::complex;\nvoid fft(int N, std::vector &a, double\ \ dir) {\n int i = 0;\n for (int j = 1; j < N - 1; j++) {\n for (int\ - \ k = N >> 1; k > (i ^= k); k >>= 1)\n ;\n if (j < i) std::swap(a[i],\ - \ a[j]);\n }\n\n std::vector zeta_pow(N);\n for (int i = 0; i\ - \ < N; i++) {\n double theta = M_PI / N * i * dir;\n zeta_pow[i]\ - \ = {cos(theta), sin(theta)};\n }\n\n for (int m = 1; m < N; m *= 2) {\n\ - \ for (int y = 0; y < m; y++) {\n cmplx fac = zeta_pow[N / m\ - \ * y];\n for (int x = 0; x < N; x += 2 * m) {\n int\ - \ u = x + y;\n int v = x + y + m;\n cmplx s = a[u]\ - \ + fac * a[v];\n cmplx t = a[u] - fac * a[v];\n \ - \ a[u] = s;\n a[v] = t;\n }\n }\n }\n}\n\ - template \nstd::vector conv_cmplx(const std::vector &a,\ - \ const std::vector &b) {\n int N = 1;\n while (N < (int)a.size() + (int)b.size())\ - \ N *= 2;\n std::vector a_(N), b_(N);\n for (int i = 0; i < (int)a.size();\ + \ k = N >> 1; k > (i ^= k); k >>= 1) {}\n if (j < i) std::swap(a[i], a[j]);\n\ + \ }\n\n std::vector zeta_pow(N);\n for (int i = 0; i < N; i++)\ + \ {\n double theta = M_PI / N * i * dir;\n zeta_pow[i] = {cos(theta),\ + \ sin(theta)};\n }\n\n for (int m = 1; m < N; m *= 2) {\n for (int\ + \ y = 0; y < m; y++) {\n cmplx fac = zeta_pow[N / m * y];\n \ + \ for (int x = 0; x < N; x += 2 * m) {\n int u = x + y;\n \ + \ int v = x + y + m;\n cmplx s = a[u] + fac * a[v];\n\ + \ cmplx t = a[u] - fac * a[v];\n a[u] = s;\n \ + \ a[v] = t;\n }\n }\n }\n}\ntemplate \nstd::vector conv_cmplx(const std::vector &a, const std::vector\ + \ &b) {\n int N = 1;\n while (N < (int)a.size() + (int)b.size()) N *= 2;\n\ + \ std::vector a_(N), b_(N);\n for (int i = 0; i < (int)a.size();\ \ i++) a_[i] = a[i];\n for (int i = 0; i < (int)b.size(); i++) b_[i] = b[i];\n\ \ fft(N, a_, 1);\n fft(N, b_, 1);\n for (int i = 0; i < N; i++) a_[i]\ \ *= b_[i];\n fft(N, a_, -1);\n for (int i = 0; i < N; i++) a_[i] /= N;\n\ @@ -144,7 +143,7 @@ data: isVerificationFile: true path: tree/test/frequency_table_of_tree_distance.test.cpp requiredBy: [] - timestamp: '2022-01-08 20:23:44+09:00' + timestamp: '2024-09-22 15:59:27+09:00' verificationStatus: TEST_ACCEPTED verifiedWith: [] documentation_of: tree/test/frequency_table_of_tree_distance.test.cpp