摘要:
LIS:最长上升子序列问题,经典dp问题。 状态用一维来表示f(i) #include<iostream> using namespace std; const int N = 1010; int f[N]; int s[N]; int n, res; int main(){ cin >> n; f 阅读全文
摘要:
很久之前就看见过这个网站,今天突然想做一下试试hh 题面 方法 用的kmp。。。搞了好半天 #include<iostream> #include<cstring> using namespace std; const int N = 10010; char res[2][N]; int cnt, 阅读全文
摘要:
分组背包:有若干个商品的小组,每个小组里面有若干个商品,每一组只能选1或0个商品的背包问题。 #include<iostream> using namespace std; #define PII pair<int, int> #define v first #define w second con 阅读全文
摘要:
技巧:蚂蚁相撞反向行驶,可以看成是两个蚂蚁穿过了对方,这个不影响答案 #include<iostream> using namespace std; const int N = 60; int a[N]; int n; int main(){ cin >> n; for(int i = 0; i < 阅读全文
摘要:
完全背包:每一种物品可以选任意多次的背包问题。 经过分析,可以在01背包的代码基础上,增加一层循环,有以下暴力代码$O(n^3)$ #include<iostream> using namespace std; const int N = 1010; int n, m; int w[N], v[N] 阅读全文