随笔分类 -  模板题目

摘要:P3809 【模板】后缀排序 1 #include <bits/stdc++.h> 2 using namespace std; 3 const int maxn = 1e6+5; 4 char s[maxn]; 5 int sa[maxn], t[maxn], t2[maxn], c[maxn]; 阅读全文
posted @ 2019-10-23 18:42 麻辣猪仔 阅读(177) 评论(0) 推荐(0)
摘要:P3373 【模板】线段树 2 1 #include <bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 const int maxn = 1e5+5; 5 ll a[maxn], add[maxn*4], mul[max 阅读全文
posted @ 2019-10-23 17:06 麻辣猪仔 阅读(169) 评论(0) 推荐(0)
摘要:P3372 【模板】线段树 1 线段树 1 #include <bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 const int maxn = 1e5+5; 5 ll a[maxn], add[maxn*4], sum 阅读全文
posted @ 2019-10-23 17:05 麻辣猪仔 阅读(177) 评论(0) 推荐(0)
摘要:P3402 【模板】可持久化并查集 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int maxn = 1e5+5; 4 int n, m; 5 int L[maxn*30], R[maxn*30], fa[maxn*30], de 阅读全文
posted @ 2019-10-23 17:04 麻辣猪仔 阅读(115) 评论(0) 推荐(0)
摘要:P3367 【模板】并查集 1 #include <bits/stdc++.h> 2 using namespace std; 3 const int maxn = 1e4+5; 4 int pa[maxn], n, m; 5 void init() { 6 for (int i = 1; i <= 阅读全文
posted @ 2019-10-23 17:02 麻辣猪仔 阅读(145) 评论(0) 推荐(0)
摘要:P3370 【模板】字符串哈希 1 #include <bits/stdc++.h> 2 using namespace std; 3 typedef unsigned long long llu; 4 const int maxn = 10005; 5 llu base = 131, mod = 阅读全文
posted @ 2019-10-23 13:32 麻辣猪仔 阅读(184) 评论(0) 推荐(0)
摘要:卢斯卡定理 $\because C_{p}^{i}=\frac{p!}{i!(p-i)!} = \frac{p}{i}\frac{(p-1)!}{(i-1)!(p-1-(i-1))!} = \frac{p}{i}C_{i-1}^{p-1}$ $\therefore C_{p}^{i}\equiv \ 阅读全文
posted @ 2019-10-22 20:26 麻辣猪仔 阅读(146) 评论(0) 推荐(0)
摘要:P5357 【模板】AC自动机(二次加强版) 该代码只有76分,一些样例超时 1 #include <bits/stdc++.h> 2 using namespace std; 3 const int maxn = 2e6+5; 4 struct word { 5 int num; // 出现次数 阅读全文
posted @ 2019-10-21 13:08 麻辣猪仔 阅读(173) 评论(0) 推荐(0)
摘要:P3808 【模板】AC自动机(简单版) 1 #include <bits/stdc++.h> 2 using namespace std; 3 const int maxn = 1e6+5; 4 struct Aho_Corasock_Automaton { 5 struct node { 6 i 阅读全文
posted @ 2019-10-20 21:58 麻辣猪仔 阅读(138) 评论(0) 推荐(0)
摘要:P3796 【模板】AC自动机(加强版) 1 #include <bits/stdc++.h> 2 using namespace std; 3 const int maxn = 1e6+5; 4 struct word { 5 string str; 6 int num; // 出现次数 7 in 阅读全文
posted @ 2019-10-20 21:58 麻辣猪仔 阅读(120) 评论(0) 推荐(0)
摘要:51Nod1127 1 #include <iostream> 2 #include <string> 3 using namespace std; 4 const int inf = 0x3f3f3f3f; 5 int vis[26]; 6 int main() { 7 string s; cin 阅读全文
posted @ 2019-10-20 20:11 麻辣猪仔 阅读(151) 评论(0) 推荐(0)
摘要:hdu5687 1 #include <bits/stdc++.h> 2 using namespace std; 3 const int maxn = 1e5+5, n = 26; 4 struct node { 5 int next[26]; 6 int cnt; 7 void init() { 阅读全文
posted @ 2019-10-20 19:41 麻辣猪仔 阅读(109) 评论(0) 推荐(0)
摘要:P3805 【模板】manacher算法 1 #include <bits/stdc++.h> 2 using namespace std; 3 const int maxn = 11000005; 4 int n, len, ans; 5 int r[maxn*2]; 6 char tmp[max 阅读全文
posted @ 2019-10-20 16:39 麻辣猪仔 阅读(123) 评论(0) 推荐(0)
摘要:Rabbit的字符串 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int maxn = 1e5+5; 4 char s[maxn]; 5 int get_min_pos() { 6 int ans = 0, cmp = 1, k 阅读全文
posted @ 2019-10-20 16:14 麻辣猪仔 阅读(199) 评论(0) 推荐(0)
摘要:P5410 【模板】扩展 KMP 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int maxn = 1e6+5; 4 int q, nxt[maxn], extend[maxn]; 5 string a, b; 6 void ge 阅读全文
posted @ 2019-10-20 15:47 麻辣猪仔 阅读(150) 评论(0) 推荐(0)
摘要:P3375 【模板】KMP字符串匹配 1 #include <bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 const int maxn = 1e6+5; 5 char s1[maxn], s2[maxn]; 6 in 阅读全文
posted @ 2019-10-20 15:45 麻辣猪仔 阅读(130) 评论(0) 推荐(0)
摘要:P3366【模板】最小生成树 Kruskal 1 #include <bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 const int maxn = 5005; 5 int fa[maxn], n, m, ans = 阅读全文
posted @ 2019-10-17 22:05 麻辣猪仔 阅读(143) 评论(0) 推荐(0)
摘要:P1226 【模板】快速幂||取余运算 在计算$a*b\ \%\ p$和$a^{b}\ \%\ p$的时候,我们通常采用快速乘和快速幂来解决$long\ long$乘法溢出的问题 快速乘$a*b\ \%\ p$ 1 ll qmul(ll a, ll b, ll p) { 2 ll res = 0; 阅读全文
posted @ 2019-10-17 20:05 麻辣猪仔 阅读(160) 评论(0) 推荐(0)