上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 17 下一页
摘要: 链接:https://www.luogu.com.cn/problem/P1929 题目: 思路:动态规划:以times[i]表示跳到第i号台阶的最小步数。 如果height[i] == height[i-1] + 1那么显然有times[i] = times[i-1] + 1 然后是遍历的状态转移 阅读全文
posted @ 2024-05-26 09:58 WHUStar 阅读(47) 评论(0) 推荐(0)
摘要: 链接:https://www.luogu.com.cn/problem/P1853 题目: 总的思路就是完全背包模板加上空间优化 完全背包参考:https://blog.csdn.net/qq_40802813/article/details/119609917 空间优化见代码 #define _C 阅读全文
posted @ 2024-05-25 22:32 WHUStar 阅读(17) 评论(0) 推荐(0)
摘要: 链接:https://www.luogu.com.cn/problem/P1057 思路:左手倒右手,建立递推方程 建立初始参数:定义dp[j][k]是第k次,以j结尾的方法,就是传k次最后传到j的方法。 那么状态转移方程:dp[j][k]=dp[next][k-1]+dp[before][k-1] 阅读全文
posted @ 2024-05-20 16:42 WHUStar 阅读(67) 评论(0) 推荐(0)
摘要: 链接:https://www.luogu.com.cn/problem/P1807 其实没什么难的,注意点:拓扑排序,把非1的入度为0的点及其衍生点全删了,不然会到一半无法拓扑下去。 关键在于我之前那个删点的操作,先看错误代码: ... void clearpoint(ll ix) { for (l 阅读全文
posted @ 2024-05-15 22:23 WHUStar 阅读(25) 评论(0) 推荐(0)
摘要: 链接:https://www.luogu.com.cn/problem/P3366 模板题: kruskal代码: 核心是对边的排序,遍历,选择。 #include<iostream> #include<vector> #include<algorithm> #include<math.h> #in 阅读全文
posted @ 2024-05-15 21:42 WHUStar 阅读(18) 评论(0) 推荐(0)
摘要: 链接:https://www.luogu.com.cn/problem/P1140 题目: 思路:设置递推状态:dp[i][j]表示a的前i个碱基和b的前j个碱基配对的最大值。 那么递推: 1.ans1设置为dp[i-1][j-1]+val[a[i]][b[j]]就是说a[i]和b[j]可以凑一对, 阅读全文
posted @ 2024-05-15 16:25 WHUStar 阅读(11) 评论(0) 推荐(0)
摘要: 思路:由于是一棵n节点,n-1边的图,所以必然没有环,那么从任何一个节点出发都必然达到另外一个节点。 如果子节点的dp大于0,那么父节点加上,否则砍掉(不加) 同时如果visit过了那就不用visit,总体复杂度为O(n)。 代码: #include<iostream> #include<vecto 阅读全文
posted @ 2024-05-15 14:55 WHUStar 阅读(11) 评论(0) 推荐(0)
摘要: 链接:https://www.luogu.com.cn/problem/P1044 两种很好的思路: 代码: #include<iostream> #include<vector> #include<algorithm> #include<math.h> #include<sstream> #inc 阅读全文
posted @ 2024-05-15 13:47 WHUStar 阅读(20) 评论(0) 推荐(0)
摘要: 链接:https://www.luogu.com.cn/problem/P1347 题目: 由于数据量很小,所以可以在线处理数据。 首先判断有没有环(这里不一定可以根据拓扑排序写出来,因为有的环可以只有部分节点,所以必须遍历所有节点的路径,判断有没有环); 然后查看入度为0的点,如果没有环而且入度为 阅读全文
posted @ 2024-05-14 10:18 WHUStar 阅读(57) 评论(0) 推荐(0)
摘要: #include<iostream> #include<vector> #include<algorithm> #include<math.h> #include<sstream> #include<string> #include<string.h> #include<iomanip> #incl 阅读全文
posted @ 2024-05-12 15:38 WHUStar 阅读(49) 评论(0) 推荐(0)
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 17 下一页