摘要: 广度优先搜索小技巧 使用bool inq(in queue)来记录某一节点是不是入过队(而不是是否被访问) 矩阵的块 求给定的矩阵中块的个数 BFS解法 #include<queue> #include<iostream> using namespace std; int X[] = { 0,0,1 阅读全文
posted @ 2021-09-03 20:05 小帆敲代码 阅读(15) 评论(0) 推荐(0) 编辑
摘要: DFS解决什么问题 给定一个序列,枚举这个序列的所有子序列(可以不连续) 枚举从N个整数中选择K个数的所有方案 背包问题 int n,maxC,V; int W[], C[]; void DFS(int index, int sumW, int sumC) { if (index == n) { r 阅读全文
posted @ 2021-09-03 19:20 小帆敲代码 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 输出3的全排列 //输出n的全排列 #include<algorithm> #include<iostream> using namespace std; int main() { int a[] = { 1,2,3 }; do { for (int i = 0; i < 3; i++) { pri 阅读全文
posted @ 2021-09-03 08:08 小帆敲代码 阅读(5) 评论(0) 推荐(0) 编辑
摘要: #include<queue> #include<string> #include<iostream> using namespace std; struct Fruit { int price; string name; }f1,f2,f3; struct cmp { bool operator( 阅读全文
posted @ 2021-09-03 08:00 小帆敲代码 阅读(1) 评论(0) 推荐(0) 编辑