Skip to content

Commit a3c8408

Browse files
authored
[auto-verifier] docs commit b9743e3
1 parent 3d5f5e1 commit a3c8408

21 files changed

+761
-71
lines changed

index.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ data:
66
- icon: ':heavy_check_mark:'
77
path: weilycoder/ds/group.hpp
88
title: Group Definitions
9+
- icon: ':heavy_check_mark:'
10+
path: weilycoder/ds/offline_static_range_query.hpp
11+
title: Offline Static Range Query Data Structure
912
- icon: ':heavy_check_mark:'
1013
path: weilycoder/ds/point_add_range_sum.hpp
1114
title: Point Add Range Sum using Fenwick Tree
@@ -25,6 +28,14 @@ data:
2528
- icon: ':heavy_check_mark:'
2629
path: weilycoder/graph/tarjan.hpp
2730
title: Tarjan's Algorithm for Graph Connected Problems
31+
- name: weilycoder/number-theory
32+
pages:
33+
- icon: ':heavy_check_mark:'
34+
path: weilycoder/number-theory/modint.hpp
35+
title: Modular Integer Arithmetic Utilities
36+
- icon: ':heavy_check_mark:'
37+
path: weilycoder/number-theory/prime.hpp
38+
title: Prime Number Utilities
2839
verificationCategories:
2940
- name: test
3041
pages:
@@ -43,9 +54,15 @@ data:
4354
- icon: ':heavy_check_mark:'
4455
path: test/point_add_range_sum.test.cpp
4556
title: test/point_add_range_sum.test.cpp
57+
- icon: ':heavy_check_mark:'
58+
path: test/primality_test.test.cpp
59+
title: test/primality_test.test.cpp
4660
- icon: ':heavy_check_mark:'
4761
path: test/static_range_sum.test.cpp
4862
title: test/static_range_sum.test.cpp
63+
- icon: ':heavy_check_mark:'
64+
path: test/staticrmq.test.cpp
65+
title: test/staticrmq.test.cpp
4966
- icon: ':heavy_check_mark:'
5067
path: test/strongly_connected_components.test.cpp
5168
title: test/strongly_connected_components.test.cpp

test/aplusb.test.cpp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ data:
160160
isVerificationFile: true
161161
path: test/aplusb.test.cpp
162162
requiredBy: []
163-
timestamp: '2025-10-30 21:08:13+08:00'
163+
timestamp: '2025-10-31 09:52:58+08:00'
164164
verificationStatus: TEST_ACCEPTED
165165
verifiedWith: []
166166
documentation_of: test/aplusb.test.cpp

test/biconnected_components.test.cpp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ data:
112112
isVerificationFile: true
113113
path: test/biconnected_components.test.cpp
114114
requiredBy: []
115-
timestamp: '2025-10-30 21:08:13+08:00'
115+
timestamp: '2025-10-31 09:52:58+08:00'
116116
verificationStatus: TEST_ACCEPTED
117117
verifiedWith: []
118118
documentation_of: test/biconnected_components.test.cpp

test/many_aplusb.test.cpp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ data:
162162
isVerificationFile: true
163163
path: test/many_aplusb.test.cpp
164164
requiredBy: []
165-
timestamp: '2025-10-30 21:08:13+08:00'
165+
timestamp: '2025-10-31 09:52:58+08:00'
166166
verificationStatus: TEST_ACCEPTED
167167
verifiedWith: []
168168
documentation_of: test/many_aplusb.test.cpp

test/many_aplusb_128bit.test.cpp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ data:
161161
isVerificationFile: true
162162
path: test/many_aplusb_128bit.test.cpp
163163
requiredBy: []
164-
timestamp: '2025-10-30 21:08:13+08:00'
164+
timestamp: '2025-10-31 09:52:58+08:00'
165165
verificationStatus: TEST_ACCEPTED
166166
verifiedWith: []
167167
documentation_of: test/many_aplusb_128bit.test.cpp

test/point_add_range_sum.test.cpp.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,26 @@ data:
2121
https://judge.yosupo.jp/problem/point_add_range_sum\"\n\n#line 1 \"weilycoder/ds/point_add_range_sum.hpp\"\
2222
\n\n\n\n/**\n * @file point_add_range_sum.hpp\n * @brief Point Add Range Sum using\
2323
\ Fenwick Tree\n */\n\n#line 1 \"weilycoder/ds/group.hpp\"\n\n\n\n/**\n * @file\
24-
\ group.hpp\n * @brief Group Definitions\n */\n\nnamespace weilycoder {\n/**\n\
25-
\ * @brief Additive Group\n * @tparam T Type of the elements\n */\ntemplate <typename\
26-
\ T> struct AddGroup {\n using value_type = T;\n static constexpr T operation(const\
27-
\ T &a, const T &b) { return a + b; }\n static constexpr T identity() { return\
28-
\ T{}; }\n static constexpr T inverse(const T &a) { return -a; }\n};\n} // namespace\
29-
\ weilycoder\n\n\n#line 10 \"weilycoder/ds/point_add_range_sum.hpp\"\n#include\
30-
\ <cstddef>\n#include <stdexcept>\n#include <vector>\n\nnamespace weilycoder {\n\
31-
/**\n * @brief Point Add Range Sum using Fenwick Tree (Binary Indexed Tree)\n\
24+
\ group.hpp\n * @brief Group Definitions\n */\n\n#include <limits>\n\nnamespace\
25+
\ weilycoder {\n/**\n * @brief Additive Group\n * @tparam T Type of the elements\n\
26+
\ */\ntemplate <typename T> struct AddGroup {\n using value_type = T;\n static\
27+
\ constexpr T operation(const T &a, const T &b) { return a + b; }\n static constexpr\
28+
\ T identity() { return T{}; }\n static constexpr T inverse(const T &a) { return\
29+
\ -a; }\n};\n\n/**\n * @brief Additive Monoid\n * @tparam T Type of the elements\n\
30+
\ */\ntemplate <typename T> struct AddMonoid {\n using value_type = T;\n static\
31+
\ constexpr T operation(const T &a, const T &b) { return a + b; }\n static constexpr\
32+
\ T identity() { return T{}; }\n};\n\n/**\n * @brief Minimum Monoid for numbers\n\
33+
\ * @tparam T Type of the elements, must support std::numeric_limits\n */\ntemplate\
34+
\ <typename T> struct NumberMinMonoid {\n using value_type = T;\n static constexpr\
35+
\ T operation(const T &a, const T &b) { return a < b ? a : b; }\n static constexpr\
36+
\ T identity() { return std::numeric_limits<T>::max(); }\n};\n\n/**\n * @brief\
37+
\ Maximum Monoid for numbers\n * @tparam T Type of the elements, must support\
38+
\ std::numeric_limits\n */\ntemplate <typename T> struct NumberMaxMonoid {\n \
39+
\ using value_type = T;\n static constexpr T operation(const T &a, const T &b)\
40+
\ { return a > b ? a : b; }\n static constexpr T identity() { return std::numeric_limits<T>::min();\
41+
\ }\n};\n} // namespace weilycoder\n\n\n#line 10 \"weilycoder/ds/point_add_range_sum.hpp\"\
42+
\n#include <cstddef>\n#include <stdexcept>\n#include <vector>\n\nnamespace weilycoder\
43+
\ {\n/**\n * @brief Point Add Range Sum using Fenwick Tree (Binary Indexed Tree)\n\
3244
\ * @tparam Group A group defining the operation and identity element,\n * \
3345
\ must be associative and commutative (i.e. Abelian group).\n */\n\
3446
template <typename Group> struct PointAddRangeSum {\n using value_type = typename\
@@ -91,7 +103,7 @@ data:
91103
isVerificationFile: true
92104
path: test/point_add_range_sum.test.cpp
93105
requiredBy: []
94-
timestamp: '2025-10-30 21:08:13+08:00'
106+
timestamp: '2025-10-31 09:52:58+08:00'
95107
verificationStatus: TEST_ACCEPTED
96108
verifiedWith: []
97109
documentation_of: test/point_add_range_sum.test.cpp

test/primality_test.test.cpp.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
data:
3+
_extendedDependsOn:
4+
- icon: ':heavy_check_mark:'
5+
path: weilycoder/number-theory/modint.hpp
6+
title: Modular Integer Arithmetic Utilities
7+
- icon: ':heavy_check_mark:'
8+
path: weilycoder/number-theory/prime.hpp
9+
title: Prime Number Utilities
10+
_extendedRequiredBy: []
11+
_extendedVerifiedWith: []
12+
_isVerificationFailed: false
13+
_pathExtension: cpp
14+
_verificationStatusIcon: ':heavy_check_mark:'
15+
attributes:
16+
'*NOT_SPECIAL_COMMENTS*': ''
17+
PROBLEM: https://judge.yosupo.jp/problem/primality_test
18+
links:
19+
- https://judge.yosupo.jp/problem/primality_test
20+
bundledCode: "#line 1 \"test/primality_test.test.cpp\"\n#define PROBLEM \"https://judge.yosupo.jp/problem/primality_test\"\
21+
\n\n#line 1 \"weilycoder/number-theory/prime.hpp\"\n\n\n\n/**\n * @file prime.hpp\n\
22+
\ * @brief Prime Number Utilities\n */\n\n#line 1 \"weilycoder/number-theory/modint.hpp\"\
23+
\n\n\n\n#include <cstdint>\n\n/**\n * @file modint.hpp\n * @brief Modular Integer\
24+
\ Arithmetic Utilities\n */\n\nnamespace weilycoder {\n/**\n * @brief Perform\
25+
\ modular multiplication for 64-bit integers.\n * @tparam bit32 If true, won't\
26+
\ use 128-bit arithmetic. You should ensure that\n * all inputs are small\
27+
\ enough to avoid overflow (i.e. bit-32).\n * @param a The first multiplicand.\n\
28+
\ * @param b The second multiplicand.\n * @param modulus The modulus.\n * @return\
29+
\ (a * b) % modulus\n */\ntemplate <bool bit32 = false>\nuint64_t modular_multiply_64(uint64_t\
30+
\ a, uint64_t b, uint64_t modulus) {\n if constexpr (bit32)\n return a * b\
31+
\ % modulus;\n else\n return static_cast<unsigned __int128>(a) * b % modulus;\n\
32+
}\n\n/**\n * @brief Perform modular exponentiation for 64-bit integers.\n * @tparam\
33+
\ bit32 If true, won't use 128-bit arithmetic. You should ensure that\n * \
34+
\ all inputs are small enough to avoid overflow (i.e. bit-32).\n * @param\
35+
\ base The base number.\n * @param exponent The exponent.\n * @param modulus The\
36+
\ modulus.\n * @return (base^exponent) % modulus\n */\ntemplate <bool bit32 =\
37+
\ false>\nconstexpr uint64_t fast_power_64(uint64_t base, uint64_t exponent, uint64_t\
38+
\ modulus) {\n uint64_t result = 1 % modulus;\n base %= modulus;\n while (exponent\
39+
\ > 0) {\n if (exponent & 1)\n result = modular_multiply_64<bit32>(result,\
40+
\ base, modulus);\n base = modular_multiply_64<bit32>(base, base, modulus);\n\
41+
\ exponent >>= 1;\n }\n return result;\n}\n} // namespace weilycoder\n\n\n\
42+
#line 11 \"weilycoder/number-theory/prime.hpp\"\n#include <type_traits>\n\nnamespace\
43+
\ weilycoder {\n/**\n * @brief Miller-Rabin primality test for a given base.\n\
44+
\ * @tparam bit32 If true, won't use 128-bit arithmetic. You should ensure that\n\
45+
\ * all inputs are small enough to avoid overflow (i.e. bit-32).\n * @tparam\
46+
\ base The base to test.\n * @param n The number to test for primality.\n * @param\
47+
\ d An odd component of n-1 (n-1 = d * 2^s).\n * @param s The exponent of 2 in\
48+
\ the factorization of n-1.\n * @return true if n is probably prime for the given\
49+
\ base, false if composite.\n */\ntemplate <bool bit32, uint64_t base>\nconstexpr\
50+
\ bool miller_rabin_test(uint64_t n, uint64_t d, uint32_t s) {\n uint64_t x =\
51+
\ fast_power_64<bit32>(base, d, n);\n if (x == 0 || x == 1 || x == n - 1)\n \
52+
\ return true;\n for (uint32_t r = 1; r < s; ++r) {\n x = modular_multiply_64<bit32>(x,\
53+
\ x, n);\n if (x == n - 1)\n return true;\n }\n return false;\n}\n\n\
54+
/**\n * @brief Variadic template to test multiple bases in Miller-Rabin test.\n\
55+
\ * @tparam bit32 If true, won't use 128-bit arithmetic. You should ensure that\n\
56+
\ * all inputs are small enough to avoid overflow (i.e. bit-32).\n * @tparam\
57+
\ base The first base to test.\n * @tparam Rest The remaining bases to test.\n\
58+
\ * @param n The number to test for primality.\n * @param d An odd component of\
59+
\ n-1 (n-1 = d * 2^s).\n * @param s The exponent of 2 in the factorization of\
60+
\ n-1.\n * @return true if n is probably prime for all given bases, false if composite.\n\
61+
\ */\ntemplate <bool bit32, uint64_t base, uint64_t... Rest>\nconstexpr std::enable_if_t<(sizeof...(Rest)\
62+
\ != 0), bool>\nmiller_rabin_test(uint64_t n, uint64_t d, uint32_t s) {\n return\
63+
\ miller_rabin_test<bit32, base>(n, d, s) &&\n miller_rabin_test<bit32,\
64+
\ Rest...>(n, d, s);\n}\n\n/**\n * @brief Miller-Rabin primality test using multiple\
65+
\ bases.\n * @tparam bit32 If true, won't use 128-bit arithmetic. You should ensure\
66+
\ that\n * all inputs are small enough to avoid overflow (i.e. bit-32).\n\
67+
\ * @tparam bases The bases to test.\n * @param n The number to test for primality.\n\
68+
\ * @return true if n is probably prime, false if composite.\n */\ntemplate <bool\
69+
\ bit32, uint64_t... bases> constexpr bool miller_rabin(uint64_t n) {\n if (n\
70+
\ < 2)\n return false;\n if (n == 2 || n == 3)\n return true;\n if (n\
71+
\ % 2 == 0)\n return false;\n\n uint64_t d = n - 1, s = 0;\n for (; d % 2\
72+
\ == 0; d /= 2)\n ++s;\n\n return miller_rabin_test<bit32, bases...>(n, d,\
73+
\ s);\n}\n\n/**\n * @brief Miller-Rabin primality test optimized for 64-bit integers.\n\
74+
\ * Uses a fixed set of bases that guarantee correctness\n * for\
75+
\ 64-bit integers.\n * @param n The number to test for primality.\n * @return\
76+
\ true if n is prime, false if not prime.\n */\nconstexpr bool miller_rabin64(uint64_t\
77+
\ n) {\n return miller_rabin<false, 2, 325, 9375, 28178, 450775, 9780504, 1795265022>(n);\n\
78+
}\n\n/**\n * @brief Miller-Rabin primality test optimized for 32-bit integers.\n\
79+
\ * Uses a fixed set of bases that guarantee correctness\n * for\
80+
\ 32-bit integers.\n * @param n The number to test for primality.\n * @return\
81+
\ true if n is prime, false if not prime.\n */\nconstexpr bool miller_rabin32(uint32_t\
82+
\ n) { return miller_rabin<true, 2, 7, 61>(n); }\n} // namespace weilycoder\n\n\
83+
\n#line 5 \"test/primality_test.test.cpp\"\n#include <iostream>\nusing namespace\
84+
\ std;\nusing namespace weilycoder;\n\nint main() {\n cin.tie(nullptr)->sync_with_stdio(false);\n\
85+
\ cin.exceptions(cin.failbit | cin.badbit);\n size_t q;\n cin >> q;\n while\
86+
\ (q--) {\n uint64_t n;\n cin >> n;\n if (n <= UINT32_MAX)\n cout\
87+
\ << (miller_rabin32(n) ? \"Yes\\n\" : \"No\\n\");\n else\n cout << (miller_rabin64(n)\
88+
\ ? \"Yes\\n\" : \"No\\n\");\n }\n return 0;\n}\n"
89+
code: "#define PROBLEM \"https://judge.yosupo.jp/problem/primality_test\"\n\n#include\
90+
\ \"../weilycoder/number-theory/prime.hpp\"\n#include <cstdint>\n#include <iostream>\n\
91+
using namespace std;\nusing namespace weilycoder;\n\nint main() {\n cin.tie(nullptr)->sync_with_stdio(false);\n\
92+
\ cin.exceptions(cin.failbit | cin.badbit);\n size_t q;\n cin >> q;\n while\
93+
\ (q--) {\n uint64_t n;\n cin >> n;\n if (n <= UINT32_MAX)\n cout\
94+
\ << (miller_rabin32(n) ? \"Yes\\n\" : \"No\\n\");\n else\n cout << (miller_rabin64(n)\
95+
\ ? \"Yes\\n\" : \"No\\n\");\n }\n return 0;\n}"
96+
dependsOn:
97+
- weilycoder/number-theory/prime.hpp
98+
- weilycoder/number-theory/modint.hpp
99+
isVerificationFile: true
100+
path: test/primality_test.test.cpp
101+
requiredBy: []
102+
timestamp: '2025-10-31 09:52:58+08:00'
103+
verificationStatus: TEST_ACCEPTED
104+
verifiedWith: []
105+
documentation_of: test/primality_test.test.cpp
106+
layout: document
107+
redirect_from:
108+
- /verify/test/primality_test.test.cpp
109+
- /verify/test/primality_test.test.cpp.html
110+
title: test/primality_test.test.cpp
111+
---

test/static_range_sum.test.cpp.md

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,33 @@ data:
2020
bundledCode: "#line 1 \"test/static_range_sum.test.cpp\"\n#define PROBLEM \"https://judge.yosupo.jp/problem/static_range_sum\"\
2121
\n\n#line 1 \"weilycoder/ds/static_range_sum.hpp\"\n\n\n\n/**\n * @file static_range_sum.hpp\n\
2222
\ * @brief Static Range Sum using Prefix Sums\n */\n\n#line 1 \"weilycoder/ds/group.hpp\"\
23-
\n\n\n\n/**\n * @file group.hpp\n * @brief Group Definitions\n */\n\nnamespace\
24-
\ weilycoder {\n/**\n * @brief Additive Group\n * @tparam T Type of the elements\n\
25-
\ */\ntemplate <typename T> struct AddGroup {\n using value_type = T;\n static\
26-
\ constexpr T operation(const T &a, const T &b) { return a + b; }\n static constexpr\
27-
\ T identity() { return T{}; }\n static constexpr T inverse(const T &a) { return\
28-
\ -a; }\n};\n} // namespace weilycoder\n\n\n#line 10 \"weilycoder/ds/static_range_sum.hpp\"\
29-
\n#include <cstddef>\n#include <stdexcept>\n#include <vector>\n\nnamespace weilycoder\
30-
\ {\n/**\n * @brief Static Range Sum using Prefix Sums\n * @tparam Group A group\
31-
\ defining the operation and identity element,\n * must be associative\
32-
\ and invertible (i.e. Group).\n */\ntemplate <typename Group> struct StaticRangeSum\
33-
\ {\n using value_type = typename Group::value_type;\n using T = value_type;\n\
34-
\nprivate:\n std::vector<T> prefix_sum;\n\npublic:\n /**\n * @brief Constructs\
35-
\ a StaticRangeSum for n elements initialized to the\n * identity element\n\
36-
\ * @param n Number of elements\n */\n explicit StaticRangeSum(const std::vector<T>\
23+
\n\n\n\n/**\n * @file group.hpp\n * @brief Group Definitions\n */\n\n#include\
24+
\ <limits>\n\nnamespace weilycoder {\n/**\n * @brief Additive Group\n * @tparam\
25+
\ T Type of the elements\n */\ntemplate <typename T> struct AddGroup {\n using\
26+
\ value_type = T;\n static constexpr T operation(const T &a, const T &b) { return\
27+
\ a + b; }\n static constexpr T identity() { return T{}; }\n static constexpr\
28+
\ T inverse(const T &a) { return -a; }\n};\n\n/**\n * @brief Additive Monoid\n\
29+
\ * @tparam T Type of the elements\n */\ntemplate <typename T> struct AddMonoid\
30+
\ {\n using value_type = T;\n static constexpr T operation(const T &a, const\
31+
\ T &b) { return a + b; }\n static constexpr T identity() { return T{}; }\n};\n\
32+
\n/**\n * @brief Minimum Monoid for numbers\n * @tparam T Type of the elements,\
33+
\ must support std::numeric_limits\n */\ntemplate <typename T> struct NumberMinMonoid\
34+
\ {\n using value_type = T;\n static constexpr T operation(const T &a, const\
35+
\ T &b) { return a < b ? a : b; }\n static constexpr T identity() { return std::numeric_limits<T>::max();\
36+
\ }\n};\n\n/**\n * @brief Maximum Monoid for numbers\n * @tparam T Type of the\
37+
\ elements, must support std::numeric_limits\n */\ntemplate <typename T> struct\
38+
\ NumberMaxMonoid {\n using value_type = T;\n static constexpr T operation(const\
39+
\ T &a, const T &b) { return a > b ? a : b; }\n static constexpr T identity()\
40+
\ { return std::numeric_limits<T>::min(); }\n};\n} // namespace weilycoder\n\n\
41+
\n#line 10 \"weilycoder/ds/static_range_sum.hpp\"\n#include <cstddef>\n#include\
42+
\ <stdexcept>\n#include <vector>\n\nnamespace weilycoder {\n/**\n * @brief Static\
43+
\ Range Sum using Prefix Sums\n * @tparam Group A group defining the operation\
44+
\ and identity element,\n * must be associative and invertible\
45+
\ (i.e. Group).\n */\ntemplate <typename Group> struct StaticRangeSum {\n using\
46+
\ value_type = typename Group::value_type;\n using T = value_type;\n\nprivate:\n\
47+
\ std::vector<T> prefix_sum;\n\npublic:\n /**\n * @brief Constructs a StaticRangeSum\
48+
\ for n elements initialized to the\n * identity element\n * @param\
49+
\ n Number of elements\n */\n explicit StaticRangeSum(const std::vector<T>\
3750
\ &data)\n : prefix_sum(data.size() + 1, Group::identity()) {\n for (size_t\
3851
\ i = 1; i <= data.size(); ++i)\n prefix_sum[i] = Group::operation(prefix_sum[i\
3952
\ - 1], data[i - 1]);\n }\n\n /**\n * @brief Constructs a StaticRangeSum from\
@@ -72,7 +85,7 @@ data:
7285
isVerificationFile: true
7386
path: test/static_range_sum.test.cpp
7487
requiredBy: []
75-
timestamp: '2025-10-30 21:08:13+08:00'
88+
timestamp: '2025-10-31 09:52:58+08:00'
7689
verificationStatus: TEST_ACCEPTED
7790
verifiedWith: []
7891
documentation_of: test/static_range_sum.test.cpp

0 commit comments

Comments
 (0)