上一页 1 ··· 16 17 18 19 20 21 22 23 24 ··· 26 下一页
摘要: DP查缺补漏之01背包优化原理 先复习一下基本知识 状态假设 DP[I][J]为前\(i\)个物品,容量小于\(j\)时的最优解(最大价值) 状态转移 DP[I][J] = max(DP[I - 1][J], DP[I - 1][J - V[I]] + W[I]) 对于第\(i\)个物品,两种可能 阅读全文
posted @ 2023-11-01 11:05 加固文明幻景 阅读(7) 评论(0) 推荐(0) 编辑
摘要: P1825 Corn Maze S 无脑深搜,然后卡死在了37pts。 #include<iostream> #include<algorithm> #include<cstdio> using namespace std; struct coord { int x, y; }; int walk[ 阅读全文
posted @ 2023-10-31 17:43 加固文明幻景 阅读(6) 评论(0) 推荐(0) 编辑
摘要: P1162 填涂颜色 大概思路,暴搜所有\(0\)点,搜到就填色,然后搜色块的时候一旦碰边就打标记,回溯之后看标记决定标\(0\)还是标\(2\)。 思路是理论可行,但是代码容易出问题。 一开始\(48pts\)的代码 #include<iostream> #include<algorithm> # 阅读全文
posted @ 2023-10-30 09:43 加固文明幻景 阅读(13) 评论(0) 推荐(0) 编辑
摘要: P2895 [USACO08FEB] Meteor Shower S 语言问题引发的惨案 题目本身不难,简单的BFS,但是写出来明明思路感觉没有问题,却不是答案错就是爆队列。 #include <iostream> #include <algorithm> #include <cstdio> #in 阅读全文
posted @ 2023-10-29 11:14 加固文明幻景 阅读(13) 评论(0) 推荐(0) 编辑
摘要: P1182 数列分段 Section II 再一次对位单杀18年的我 \(2018\) \(0pts\) #include<cctype> #include<cstdio> #include<algorithm> using std::sort; int n,a[100010],QZ_sum[100 阅读全文
posted @ 2023-10-26 16:11 加固文明幻景 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 二分答案 使用条件(最大的最小,最小的最大) 命题可以被归纳为找到使得某命题\(P(x)\)成立(或不成立)的最大(或最小)的\(x\)。 把\(P(x)\)看作一个值为真或假的函数,那么它一定在某个分界线的一侧全为真,另一侧全为假。 可以找到一个复杂度优秀的算法来检验\(P(x)\)的真假。 好理 阅读全文
posted @ 2023-10-25 17:54 加固文明幻景 阅读(16) 评论(0) 推荐(0) 编辑
摘要: while (l <= r) { mid = l + (r - l) >> 1; ...... } 这样是错误的! 由于>>的优先级问题,应用如下格式。 while (l <= r) { mid = l +( (r - l) >> 1); ...... } 阅读全文
posted @ 2023-10-24 20:36 加固文明幻景 阅读(7) 评论(0) 推荐(0) 编辑
摘要: 一开始贪心思路不对且根本没考虑重复,无脑sort后直接排组玄学了70pts。 #include <iostream> #include <algorithm> using namespace std; int n; int cnt, ans = 0x7fffffff; int a[100010]; 阅读全文
posted @ 2023-10-23 17:22 加固文明幻景 阅读(13) 评论(0) 推荐(0) 编辑
摘要: iterator是通用的遍历容器的方式 通用模板 anySet <a...> as; anySet <a...>::iterator it = as.begin(); for (; it != as.end(); it++) { cout <<(*it);//即迭代器it指向的元素 } 四种迭代器 阅读全文
posted @ 2023-10-23 16:49 加固文明幻景 阅读(112) 评论(0) 推荐(0) 编辑
摘要: P1106删数问题 对2018年的我一次完美的对位单杀 2018 44pts Code #include<cstdio> #include<iostream> #include<algorithm> using std::cin; using std::cout; using std::sort; 阅读全文
posted @ 2023-10-22 22:39 加固文明幻景 阅读(7) 评论(0) 推荐(0) 编辑
上一页 1 ··· 16 17 18 19 20 21 22 23 24 ··· 26 下一页