File tree Expand file tree Collapse file tree 5 files changed +80
-1
lines changed Expand file tree Collapse file tree 5 files changed +80
-1
lines changed Original file line number Diff line number Diff line change
1
+ AtCoder解説放送ライブラリ集
2
+ ----
3
+ ## これは何?
4
+ [ 解説放送] ( https://www.youtube.com/channel/UCtG3StnbhxHxXfE6Q4cPZwQ ) で作ったライブラリを公開しています。
5
+
6
+ ## 目次
7
+
8
+ ### ユーティリティ
9
+ | 名前| コード| 説明|
10
+ | :--| :--| :--|
11
+ | テンプレート| [ template.cpp] ( template.cpp ) ||
12
+ | ModInt| [ mint.cpp] ( mint.cpp ) | 自動でmodを取ってくれる整数型|
13
+
14
+ ### データ構造
15
+ | 名前| コード| 説明|
16
+ | :--| :--| :--|
17
+ | BIT| [ bit.cpp] ( bit.cpp ) | Binary Indexed Tree (Fenwick Tree)|
18
+
19
+ ### 数学
20
+ | 名前| コード| 説明|
21
+ | :--| :--| :--|
22
+ | GCD/LCM| [ gcd.cpp] ( gcd.cpp ) | 最大公約数と最小公倍数|
23
+ | Combination| [ comb.cpp] ( comb.cpp ) | nCkをmod素数で求める|
24
+
25
+ ### グラフ
26
+ | 名前| コード| 説明|
27
+ | :--| :--| :--|
28
+ | LCA| [ lca.cpp] ( lca.cpp ) | 最小共通祖先|
29
+
30
+ ### 文字列
31
+ | 名前| コード| 説明|
32
+ | :--| :--| :--|
33
+ | KMP| [ mp.cpp] ( mp.cpp ) | 文字列検索アルゴリズム(正確にはMP)|
34
+
35
+ ### 幾何
36
+ | 名前| コード| 説明|
37
+ | :--| :--| :--|
38
+ | Vector| [ vector.cpp] ( vector.cpp ) | ベクトル(点を扱う際にも使う)|
Original file line number Diff line number Diff line change
1
+ // GCD, LCM
2
+ // https://youtu.be/8lm8o8L9Bmw?t=2285
3
+ // https://youtu.be/XI8exXVxZ-Q?t=3595
4
+ // https://youtu.be/F2p_e6iKxnk?t=843
5
+ ll gcd (ll a, ll b) { return b?gcd (b,a%b):a;}
6
+ ll lcm (ll a, ll b) { return a/gcd (a,b)*b;}
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ const int mod = 1000000007;
6
6
struct mint {
7
7
ll x; // typedef long long ll;
8
8
mint (ll x=0 ):x((x%mod+mod)%mod){}
9
+ mint operator -() const { return mint (-x);}
9
10
mint& operator +=(const mint a) {
10
11
if ((x += a.x ) >= mod) x -= mod;
11
12
return *this ;
Original file line number Diff line number Diff line change
1
+ // Morris-Pratt
2
+ // https://youtu.be/9MphwmIsO7Q?t=7283
3
+ template <typename T>
4
+ struct MP {
5
+ int n;
6
+ T t;
7
+ vector<int > a;
8
+ MP () {}
9
+ MP (const T& t): t(t) {
10
+ n = t.size ();
11
+ a = vector<int >(n+1 );
12
+ a[0 ] = -1 ;
13
+ int j = -1 ;
14
+ for (int i = 0 ; i < n; ++i) {
15
+ while (j != -1 && t[j] != t[i]) j = a[j];
16
+ j++;
17
+ a[i+1 ] = j;
18
+ }
19
+ }
20
+ int operator [](int i) { return a[i];}
21
+ vector<int > findAll (const T& s) {
22
+ vector<int > res;
23
+ int j = 0 ;
24
+ for (int i = 0 ; i < s.size (); ++i) {
25
+ while (j != -1 && t[j] != s[i]) j = a[j];
26
+ j++;
27
+ if (j == n) {
28
+ res.push_back (i-j+1 );
29
+ j = a[j];
30
+ }
31
+ }
32
+ return res;
33
+ }
34
+ };
Original file line number Diff line number Diff line change 1
- // geometry
1
+ // vector
2
2
// https://youtu.be/UWbGRhF3Ozw?t=9564
3
3
const double eps = 1e-9 ;
4
4
struct V {
You can’t perform that action at this time.
0 commit comments