摘要: 适用范围 1.有负环存在 2.有边数限制 模板 有边数限制的最短路 #include<iostream> #include<algorithm> #include<cstring> using namespace std; const int N = 510,M = 10010; int dist[ 阅读全文
posted @ 2021-07-24 15:29 Xuuxxi 阅读(32) 评论(0) 推荐(0) 编辑
摘要: #适用范围 单源正权边最短路 时间复杂度O(n^2) #模板 稠密图(n^2) Dijkstra求最短路 I #include<iostream> #include<algorithm> #include<cstring> using namespace std; const int N = 510 阅读全文
posted @ 2021-07-24 02:05 Xuuxxi 阅读(52) 评论(0) 推荐(0) 编辑
摘要: 含义 所有点都是从小编号指向大编号 是一个有序无环图 检查时遍历所有入度0的节点并删除与之相关的连线 模板 有向图的拓扑序列 #include<iostream> #include<cstring> using namespace std; const int N = 100010; int e[N 阅读全文
posted @ 2021-07-22 07:48 Xuuxxi 阅读(41) 评论(0) 推荐(0) 编辑
摘要: 模板 //起始位置为u,求v点最短路 //点之间距离为1 int bfs(int u,int v){ int tt = 0,hh = 0; memset(d,-1,sizeof d); d[u] = 0; q[0] = u; while(hh <= tt){ //取出点 int t = q[hh + 阅读全文
posted @ 2021-07-22 06:53 Xuuxxi 阅读(14) 评论(0) 推荐(0) 编辑
摘要: 模板 #include<iostream> #include<algorithm> #include<cstring> using namespace std; const int N = 100010,M = N * 2; //h是N个单链表的头节点 //ne是单链表的ne数组 //e是单个节点的 阅读全文
posted @ 2021-07-20 14:47 Xuuxxi 阅读(36) 评论(0) 推荐(0) 编辑
摘要: vector 变长数组 size() 返回元素个数 empty() 检查是否为空 clear() 清空 front()/back() 返回头尾元素 begin()/end() 迭代器 pair<a,b> 一个有a类型元素和b类型元素的结构体 .first 访问第一个元素 .second 访问第二个元 阅读全文
posted @ 2021-07-18 11:24 Xuuxxi 阅读(30) 评论(1) 推荐(0) 编辑
摘要: 回文子串的最大长度 技巧 在每两个字符中插入一个新的字符,可以不用判断字符串的奇偶,方便编程。 利用字符串哈希和二分求解 #include<iostream> #include<cstring> #include<algorithm> using namespace std; const int N 阅读全文
posted @ 2021-07-17 15:46 Xuuxxi 阅读(28) 评论(0) 推荐(0) 编辑
摘要: 作用 有时候 more niubi than kmp 比较两个区间的字符串是否一致就可以用 原理 将一个字符串看成一个P进制的数 对比时取子串可以直接相减得出 注意点: 1. 任意字符不可以映射成0,否则会出现不同的字符串都映射成0的情况,比如A,AA,AAA皆为0 2. 冲突问题:通过巧妙设置P 阅读全文
posted @ 2021-07-17 14:19 Xuuxxi 阅读(43) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <string> #include <cstring> using namespace std; class Complex{ private: string str; float real; float imag; void split() 阅读全文
posted @ 2021-07-01 17:41 Xuuxxi 阅读(37) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> #include<cstring> #include<algorithm> using namespace std; const int L=110; int sub(int *a,int *b,int La,int Lb) { if(La<Lb) return 阅读全文
posted @ 2021-06-25 10:32 Xuuxxi 阅读(60) 评论(0) 推荐(0) 编辑