加载中...

随笔分类 -  DP

摘要:https://www.acwing.com/problem/content/1585/ 状态机的解法 #include <iostream> #include <cstring> using namespace std; const int N = 100010, MOD = 1e9 + 7; i 阅读全文
posted @ 2022-08-22 20:54 英雄不问出处c 阅读(19) 评论(0) 推荐(0)
摘要:https://www.acwing.com/problem/content/description/1556/ 思路: 01背包问题的经典模型,这不过这儿的属性是bool,表示能不能,而且要你输出方案,由于方案要字典序最小,所以Ai则是能选则选,又由于是从后往前推的,所以这也暗示我们a数组要按从大 阅读全文
posted @ 2022-08-22 20:35 英雄不问出处c 阅读(20) 评论(0) 推荐(0)
摘要:https://www.acwing.com/problem/content/1531/ 思路: 最长公共子序列模型,唯一不同的一点是:他一个i可以选择多个j。 P:2 3 1 5 6 S:2 2 4 1 5 5 6 3 1 1 5 6 f[i][j]: 状态表示: 集合:在p[1,i]中出现且在s 阅读全文
posted @ 2022-08-22 20:16 英雄不问出处c 阅读(16) 评论(0) 推荐(0)
摘要:https://www.acwing.com/problem/content/1481/ 思路: 注意f数组的含义以及集合的划分。 #include<bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int a[N]; int f 阅读全文
posted @ 2022-08-22 20:03 英雄不问出处c 阅读(23) 评论(0) 推荐(0)