摘要: 蓝桥杯:不同子串 #include <iostream> #include <string> #include <map> using namespace std; int main() { string str = "0100110001010001"; // str ="aaab"; map<s 阅读全文
posted @ 2020-10-13 00:35 30天CF上蓝!!! 阅读(165) 评论(0) 推荐(0) 编辑
摘要: ###1.数组模拟队列(hh=0,tt=-1模拟的是双端队列) int q[N] int hh=0,tt=-1;队头指针和队尾指针. push -> q[++tt]=x; pop -> hh++;//从队头弹出 pop -> tt--;//从队尾弹出 empty() -> cout<<((hh<=t 阅读全文
posted @ 2020-10-09 21:55 30天CF上蓝!!! 阅读(90) 评论(0) 推荐(0) 编辑
摘要: ###upper_bound和lower_bound用于在排好序的序列中利用二分查找的方法进行查找。 #####从小到大的数组中: lower_bound(begin,end,num):从数组的begin位置到end-1位置,二分查找大于等于num的第一个元素,返回一个迭代器(该元素的地址), 不存 阅读全文
posted @ 2020-10-06 21:43 30天CF上蓝!!! 阅读(100) 评论(0) 推荐(0) 编辑
摘要: ###错误的写法 int c[N];//c[i]表示i点属于第几个连通块 dfs(1)//主函数中 void dfs(int u) { if(u>n)return; if(st[u])dfs(u+1); if(!st[u]) { c[u]=cnt; st[u]=1; } for(int i=h[u] 阅读全文
posted @ 2020-10-01 11:13 30天CF上蓝!!! 阅读(209) 评论(0) 推荐(0) 编辑
摘要: DAG(有向无环图)才有拓扑序列(有向无环图中的所有的路线必须都是单向的) 拓扑序列指,若一个由图中所有点构成的序列A满足:对于图中的每条边(x, y),x在A中都出现在y之前,则称A是该图的一个拓扑序列。 acwing—奖金(拓扑排序) #include<iostream> #include<cs 阅读全文
posted @ 2020-09-30 16:29 30天CF上蓝!!! 阅读(90) 评论(0) 推荐(0) 编辑
摘要: ###stringstream的头文件是《sstream》,stringstream可以作为中间介质,实现字符串和数字之间的转换。 数字转string double a=213; string s; stringstream ss; //注意stringstream ss(a)是错误的,因为a是数字 阅读全文
posted @ 2020-09-23 17:16 30天CF上蓝!!! 阅读(139) 评论(0) 推荐(0) 编辑
摘要: AcWing 852. spfa判断负环 #include <cstring> #include <iostream> #include <algorithm> #include <queue> using namespace std; const int N = 2010, M = 10010; 阅读全文
posted @ 2020-09-19 22:34 30天CF上蓝!!! 阅读(145) 评论(0) 推荐(0) 编辑
摘要: acwing851—spfa求最短路 #include<iostream> #include<cstring> #include<algorithm> #include<queue> using namespace std; const int N=1e5+10; int n,m; int idx, 阅读全文
posted @ 2020-09-19 21:06 30天CF上蓝!!! 阅读(130) 评论(0) 推荐(0) 编辑
摘要: int pre[N];//pre[x]=y表示节点x的前驱节点时y void print_path(int a,int b)//打印从节点a到节点b的路径 { if(a==b){printf("%d",s),return ;} printf_path(a,pre[b]) printf("%d",b) 阅读全文
posted @ 2020-09-19 20:37 30天CF上蓝!!! 阅读(112) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> #include<algorithm> #include<cstring> using namespace std; const int N=510,M=1e4+10; int n,m,k,dis[N],backup[N]; //dis数组表示dis[i]到起点 阅读全文
posted @ 2020-09-19 19:45 30天CF上蓝!!! 阅读(163) 评论(0) 推荐(0) 编辑