摘要:
01背包:指的是每种物品只能选0次或1次的背包问题。 在01背包的基础上说一下闫氏dp分析法: 状态计算使用的集合划分方法: #include<iostream> using namespace std; const int N = 1010; int n, m; int f[N][N]; int 阅读全文
摘要:
模拟一个小根堆,最重要的部分是heap_swap部分 heap_node和node_heap分别维护堆中的第a个元素是第几个插入的元素,和第k个插入的元素在堆中的位置 #include<iostream> using namespace std; const int N = 100010; int 阅读全文
摘要:
dijkstra算法的堆优化版本,把找dist数组中的最小值的复杂度优化为O(1). #include<iostream> #include<cstring> using namespace std; const int N = 150010; int heap[N], heap_node[N], 阅读全文
摘要:
循环n次,每次用离源点最近的点去更新源点到其他点的距离。 #include<iostream> #include<cstring> using namespace std; const int N = 510; int dist[N]; int d[N][N]; int st[N]; int n, 阅读全文
摘要:
按边权把边从小到大排序 用并查集加边 检查是否为连通图 #include<iostream> #include<algorithm> using namespace std; const int N = 100010, E = 200010; struct edge{ int a, b, w; bo 阅读全文
摘要:
本题练习离散化,二分找位置,数组去重。 #include<iostream> #include<algorithm> using namespace std; const int N = 100010; struct node{ int x, c; }nodes[N]; int n, m, k = 阅读全文