摘要: kmp 算法基本思路 1.初始化 j = -1,表示 pattern 当前已被匹配的最后位。2.让 i 遍历文本串 text,对每个 i,执行 3、4来试图匹配 text[i] 和 pattern[j + 1]。3.直到 j 回退到 -1 或者是 text[i] == pattern[j + 1], 阅读全文
posted @ 2023-11-14 00:09 rw156 阅读(26) 评论(0) 推荐(0)
摘要: acwing 154滑动窗口,单调队列q 存的是下标,真正的值需要再套一个a数组 1 #include<iostream> 2 using namespace std; 3 4 const int N = 1e6 + 10; 5 6 int n,k; 7 int a[N],q[N]; //q代表单调 阅读全文
posted @ 2023-11-13 17:08 rw156 阅读(15) 评论(0) 推荐(0)
摘要: 1.并查集模板 P3367 【模板】并查集 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) 1 #include <bits/stdc++.h> 2 using namespace std; 3 4 const int N = 2e5 + 10; 5 int n,m,x,y,z; 阅读全文
posted @ 2023-11-11 21:14 rw156 阅读(13) 评论(0) 推荐(0)
摘要: 1.哈希表的使用 <1> 拉链法 1 #include <cstring> 2 #include <iostream> 3 4 using namespace std; 5 6 const int N = 1e5 + 3; // 取大于1e5的第一个质数,取质数冲突的概率最小 可以百度 7 8 // 阅读全文
posted @ 2023-11-10 00:43 rw156 阅读(14) 评论(0) 推荐(0)
摘要: 1.Otoshidama - AtCoder abc085_c - Virtual Judge (vjudge.net) 1 #include<bits/stdc++.h> 2 using namespace std; 3 4 int n,Y; 5 6 int main() 7 { 8 while( 阅读全文
posted @ 2023-11-09 12:09 rw156 阅读(14) 评论(0) 推荐(0)
摘要: 1.单链表 https://www.acwing.com/problem/content/828/ 1 #include<bits/stdc++.h> 2 using namespace std; 3 4 const int N = 100010; 5 6 7 int head,e[N],ne[N] 阅读全文
posted @ 2023-11-08 13:43 rw156 阅读(15) 评论(0) 推荐(0)
摘要: 1.Good Distance - AtCoder abc133_b - Virtual Judge (vjudge.net) 判断是否为整数,用开方后平方判断是否相等,并且此题将多对数 成数组来输出 1 #include <bits/stdc++.h> 2 using namespace std; 阅读全文
posted @ 2023-11-06 23:40 rw156 阅读(25) 评论(0) 推荐(0)
摘要: 1.Counting Roads - AtCoder abc061_b - Virtual Judge (vjudge.net) 利用数组的值去替换数组的下标来简化计数过程 1 #include <bits/stdc++.h> 2 using namespace std; 3 4 int n,m,a 阅读全文
posted @ 2023-11-06 15:02 rw156 阅读(20) 评论(0) 推荐(0)
摘要: 1.Coins - AtCoder abc087_b - Virtual Judge (vjudge.net) 1 #include<bits/stdc++.h> 2 using namespace std; 3 4 long long a,b,c,x,ans; 5 int main() 6 { 7 阅读全文
posted @ 2023-11-04 22:43 rw156 阅读(14) 评论(0) 推荐(0)
摘要: 1.B - Beautiful Strings (atcoder.jp) 代码: 1 #include <bits/stdc++.h> 2 using namespace std; 3 4 int n; 5 int cnt[500]; 6 string s; 7 int mian() { 8 cin 阅读全文
posted @ 2023-11-04 16:21 rw156 阅读(30) 评论(0) 推荐(0)