上一页 1 2 3 4 5 6 ··· 8 下一页
摘要: 最小生成树 #include <iostream> #include <cstring> #include <algorithm> #include <queue> #include <vector> using namespace std; typedef pair<int, int> PII; 阅读全文
posted @ 2025-08-18 23:29 .N1nEmAn 阅读(12) 评论(0) 推荐(0)
摘要: 求最短路径 注意一下读取边的时候,最开始都设置为最大,然后读取的时候必须比现在的小才读取,用min就行。注意初始化自己到自己是0。 #include <iostream> #include <cstring> #include <algorithm> #include <vector> using 阅读全文
posted @ 2025-08-18 17:22 .N1nEmAn 阅读(7) 评论(0) 推荐(0)
摘要: 最短路径 把处理的加入队列,下次也是从队列取出来处理,直到队列空了。感觉跟我第一次错迪杰斯特拉一样,但是这个好理解也简单。 漏了两个处理:1是记录已经在队列的就不要入了。2是记录进入队列次数,超过n就是负数。 #include <iostream> #include <cstring> #inclu 阅读全文
posted @ 2025-08-18 11:50 .N1nEmAn 阅读(8) 评论(0) 推荐(0)
摘要: 每次遍历所有边权跟上次的比dist,prev+c更新。 n-1之后还可更新有负权回路。 注意prev[a]不可是INF 次数限制的最短路径 #include <iostream> #include <cstring> #include <algorithm> #include <vector> us 阅读全文
posted @ 2025-08-17 20:51 .N1nEmAn 阅读(7) 评论(0) 推荐(0)
摘要: 1 #include <iostream> #include <cstring> #include <algorithm> #include <vector> #include <climits> using namespace std; //思路就是每次构成一个最短的,下次从最短的下一个开始不断构 阅读全文
posted @ 2025-08-10 17:08 .N1nEmAn 阅读(12) 评论(0) 推荐(0)
摘要: 关于DFS其实本质就是,当path达到对应数量就输出!如果没有达到,那么看看哪些还可以选择,如果可以选择就插入path,标记不可选,然后递归,然后标记可用,然后弹出,就是这么一个套路。 DFS:达则可,否则遍历入标递标出。 BFS:队列不空出遍入。 排列数字 使用回溯法生成所有可能的排列 每次选择一 阅读全文
posted @ 2025-08-04 10:02 .N1nEmAn 阅读(7) 评论(0) 推荐(0)
摘要: 哈希表 我用的拉链法。 #include <iostream> #include <cstring> #include <algorithm> #include <vector> using namespace std; int N = 100003; vector<int> H[100003]; 阅读全文
posted @ 2025-08-02 20:54 .N1nEmAn 阅读(9) 评论(0) 推荐(0)
摘要: 堆排序 推荐:https://www.acwing.com/solution/content/120483/ #include <iostream> #include <cstring> #include <algorithm> using namespace std; int A[100100], 阅读全文
posted @ 2025-08-02 19:05 .N1nEmAn 阅读(5) 评论(0) 推荐(0)
摘要: 并查集 用一个索引代表父节点,如果根一样就是一个集合。查找的时候使用路径压缩提升效率。 #include <iostream> #include <cstring> #include <algorithm> #include <vector> using namespace std; int P[1 阅读全文
posted @ 2025-08-01 20:13 .N1nEmAn 阅读(10) 评论(0) 推荐(0)
摘要: Trie查询与插入 #include <iostream> #include <cstring> #include <algorithm> #include <vector> using namespace std; struct Trie{ int c[26];//孩子 int co;//对应字母 阅读全文
posted @ 2025-07-31 21:43 .N1nEmAn 阅读(9) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 ··· 8 下一页