摘要: 线段树 阅读全文
posted @ 2021-08-17 16:43 冯大善人 阅读(180) 评论(0) 推荐(0)
摘要: 题目链接 AcWing 3803. 数组去重 #include <iostream> #include <cstring> #include <algorithm> #include <stack> using namespace std; const int N = 60, M = 1010; i 阅读全文
posted @ 2021-08-14 23:44 冯大善人 阅读(30) 评论(0) 推荐(0)
摘要: 基础课图论复习-最短路 朴素Dijkstra算法 (适合稠密图 用邻接矩阵存图) 时间复杂度 O(\(n^2 + m\)) n表示点数, m表示边数 AcWing 849. Dijkstra求最短路I int g[N][N]; // 存储每条边 int dist[N]; // 存储1号点到每个点的最 阅读全文
posted @ 2021-08-14 01:18 冯大善人 阅读(58) 评论(0) 推荐(0)
摘要: 题目链接AcWing 1106. 山峰和山谷 经典Flood Fill 用bfs做 #include <iostream> #include <algorithm> #include <cstring> #define x first #define y second using namespace 阅读全文
posted @ 2021-08-14 01:01 冯大善人 阅读(40) 评论(0) 推荐(0)
摘要: 题目链接 AcWing1098. 城堡问题 #include <iostream> #include <cstring> #include <algorithm> #define x first #define y second using namespace std; typedef pair<i 阅读全文
posted @ 2021-08-14 00:58 冯大善人 阅读(39) 评论(0) 推荐(0)
摘要: 题目链接 AcWing1097. 池塘计数 经典FloodFill 用bfs做 #include <iostream> #include <algorithm> #include <cstring> #define x first #define y second using namespace s 阅读全文
posted @ 2021-08-14 00:56 冯大善人 阅读(45) 评论(0) 推荐(0)
摘要: #include <iostream> #include <algorithm> #include <cstring> using namespace std; const int N = 110; int n, m; int s[N], f[N]; int v[N][N], w[N][N]; in 阅读全文
posted @ 2021-08-13 13:24 冯大善人 阅读(19) 评论(0) 推荐(0)
摘要: 题目链接 AcWing 5.多重背包问题II 二进制优化多重背包 二进制优化原理(不难证明) 对于一个整数S,不妨设 S = \((1101011)_{2}\) 为 7位2进制整数, 我们可以由{\({2^0,2^1,2^2,2^3,2^4,2^5,2^6,2^7}\)}(集合中的元素要么选,要么不 阅读全文
posted @ 2021-08-13 13:23 冯大善人 阅读(27) 评论(0) 推荐(0)
摘要: 题目链接AcWing 4.多重背包问题 朴素版 #include <iostream> #include <cstring> #include <algorithm> using namespace std; const int N = 110; int n, m; int f[N][N]; //f 阅读全文
posted @ 2021-08-13 13:18 冯大善人 阅读(33) 评论(0) 推荐(0)
摘要: 题目链接 AcWing 3. 完全背包问题 朴素法 #include <iostream> #include <cstring> #include <algorithm> using namespace std; const int N = 1010; int n, m; int v, w; int 阅读全文
posted @ 2021-08-13 13:17 冯大善人 阅读(41) 评论(0) 推荐(0)