摘要: This is a chanllenging problem on codeforces with a diffcuilt score of 1400. It presents a intressting chanllege that can be solved by using the princ 阅读全文
posted @ 2024-02-29 22:12 _Yxc 阅读(14) 评论(0) 推荐(0)
摘要: This is a programing problem on codefores with a difficulty score of 1400. It presents an intresting challenge that can be solved using the principle 阅读全文
posted @ 2024-02-28 21:02 _Yxc 阅读(14) 评论(0) 推荐(0)
摘要: This is a programing problem on Codeforces with a difficulty score of 1400. Its solution is based on the Inclusion-Exclusion principle. https://codefo 阅读全文
posted @ 2024-02-27 20:40 _Yxc 阅读(10) 评论(0) 推荐(0)
摘要: 题意:每个人有一个happ值,n个人,n - 1条有向边,u是v的上司,求happy值最大。 限制条件是u和v不能同时参加。 分析:没想到一个v居然有很多上司,更没想到n-1条边居然是个森林。 //没想到,一个员工居然可以有那么多上司。。 void solve(){ int n; cin >> n; 阅读全文
posted @ 2024-01-18 10:39 _Yxc 阅读(15) 评论(0) 推荐(0)
摘要: 题意:一个有根树,树枝上有苹果,问保留m个树枝,最多能保留多少个苹果。 分析:树形dp,给定了m树枝数,显然可能的状态集合应该是节点保留的边数以及对应的最大保留苹果数。不难设计出转移方程: dp[u][i] = max(dp[u][i], dp[v][i - j - 1] + w); void so 阅读全文
posted @ 2024-01-18 10:13 _Yxc 阅读(13) 评论(0) 推荐(0)
摘要: https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=447&page=show_problem&problem=4183 题意:给定两个字符串a,b,问最少多少次操作可以把a变成b。每次操作可以选择一段 阅读全文
posted @ 2024-01-17 11:33 _Yxc 阅读(12) 评论(0) 推荐(0)
摘要: https://www.luogu.com.cn/problem/P1775 题意:合并石子,每次合并的代价为相邻两堆的重量,求最小代价。 分析:区间dp,枚举所有的状态为下一次的区间长度计算需要的子集做准备,初始dp[i][i] = 0,前缀和计算合成代价。 void solve(){ int n 阅读全文
posted @ 2024-01-17 10:36 _Yxc 阅读(59) 评论(0) 推荐(0)
摘要: 题意:二维平面内n个糖果,问吃完所有糖果走的最小距离。 初始时坐标为0,0。 n <= 15 分析:经典状压模板题。 void solve(){ int n; cin >> n; vector<pair<double, double>> a(n); for (auto& x : a){ cin >> 阅读全文
posted @ 2024-01-17 09:20 _Yxc 阅读(12) 评论(0) 推荐(0)
摘要: https://www.acwing.com/problem/content/description/294/ 题意:n,m平面内,有些格子可以放士兵,士兵的攻击范围是一个十字形,在士兵不攻击其他士兵的前提下,求方格内最多放置的士兵数。 n <= 100, m <= 10 分析:状压dp,状态是三维 阅读全文
posted @ 2024-01-16 11:13 _Yxc 阅读(17) 评论(0) 推荐(0)
摘要: 题意:n*m的平面,问有多少种方式能被1 * 2的小条子放满。n, m <= 11。 分析:状压DP。由上一行转到当前行。 定义状态竖着放的上半部分为1,可知上一行&当前行为0,并且上一行|当前行不含奇数长度0。剪枝 + 交换n,m降复杂度。 没想到如何表示状态跟转移 定义竖着木头的上半部分为1,其 阅读全文
posted @ 2024-01-16 10:02 _Yxc 阅读(24) 评论(0) 推荐(0)