摘要: #include<iostream> #include<cstring> using namespace std; const int N = 100010; const int M = N * 2;//边要存两次 int n; int e[M], ne[M], h[N], idx = 0; boo 阅读全文
posted @ 2023-10-11 17:30 敲代码的6 阅读(15) 评论(0) 推荐(0)
摘要: bfs 可用于权值相同为1的时候求最短路问题 #include<iostream> #include<algorithm> #include<cstring> #include<queue> using namespace std; const int N = 110; typedef pair<i 阅读全文
posted @ 2023-09-26 18:48 敲代码的6 阅读(30) 评论(0) 推荐(0)
摘要: 第一种 类似于上一个题目得变形 #include<iostream> using namespace std; const int N = 20; int n; char p[N][N]; bool col[N], dg[N*2], udg[N*2];//注意范围的设置 void dfs(int u 阅读全文
posted @ 2023-09-24 20:15 敲代码的6 阅读(27) 评论(0) 推荐(0)
摘要: dfs排列数字 #include<iostream> using namespace std; const int N=10; int path[N]; bool str[N]; int n; void dfs(int u){ if(u==n){ for(int i=0;i<n;i++)printf 阅读全文
posted @ 2023-09-21 21:43 敲代码的6 阅读(26) 评论(0) 推荐(0)
摘要: 1.acwing离散化的题目(电影) 2. 阅读全文
posted @ 2023-09-21 08:16 敲代码的6 阅读(9) 评论(0) 推荐(0)
摘要: 系统为某一程序分配空间时和空间大小无关,只和申请次数有关 vector 1.遍历方式 初始化可以 =make_pair(1 , 2); 也可以 ={1,2}; string substr()::取子集,输入区间下标; c_str() ::返回首地址 queue 优先队列(堆) 默认大跟堆 小跟对方式 阅读全文
posted @ 2023-09-16 16:18 敲代码的6 阅读(25) 评论(0) 推荐(0)
摘要: 开放寻址法 #include<iostream> #include<algorithm> #include<cstring> #include<string> using namespace std; const int N =200003,null=0x3f3f3f3f; int a[N]; in 阅读全文
posted @ 2023-09-16 10:19 敲代码的6 阅读(22) 评论(0) 推荐(0)
摘要: 哈希表 拉链法 #include <cstring> #include<string> #include <iostream> using namespace std; const int N = 100003; int h[N], e[N], ne[N], idx; void insert(int 阅读全文
posted @ 2023-09-13 21:37 敲代码的6 阅读(34) 评论(0) 推荐(0)
摘要: 并查集模板 注意查找到后查找的节点直接连接根节点 #include<iostream> using namespace std; const int N = 100010; int p[N]; //关键记住find函数 int find(int a) { if (p[a] != a) p[a] = 阅读全文
posted @ 2023-09-10 23:29 敲代码的6 阅读(15) 评论(0) 推荐(0)
摘要: KMP算法 int n, m; cin >> n >> a + 1 >> m >> b + 1;这两行代码的意思是输入字符串a,b但是是从下标1开始输入的 可以按照此方式输入字符串,但是输出必须按照下标for循环输出,不能直接输出 //注意next数组是对于要匹配的串写的(短的串) 1 #inclu 阅读全文
posted @ 2023-09-09 16:08 敲代码的6 阅读(25) 评论(0) 推荐(0)