摘要: 链接:https://www.luogu.com.cn/problem/CF1915F 题目: 比较隐蔽的逆序对问题 先按begin排:sort 然后再用归并记录end的逆序 #include<iostream> #include<vector> #include<algorithm> #inclu 阅读全文
posted @ 2024-04-07 15:01 WHUStar 阅读(50) 评论(0) 推荐(0)
摘要: https://codeforces.com/problemset/problem/1933/E 前缀和 + 二分查找,之前一直用三分,好像不太行? 总之找到u和u+1的就行 代码: #include<iostream> #include<vector> #include<algorithm> #i 阅读全文
posted @ 2024-04-07 13:32 WHUStar 阅读(41) 评论(0) 推荐(0)
摘要: #include<iostream> #include<map> #include<algorithm> #include<math.h> using namespace std; /*3372*/ typedef long long ll; const int N = 1e5 + 10; ll a 阅读全文
posted @ 2024-04-06 10:09 WHUStar 阅读(8) 评论(0) 推荐(0)
摘要: 题目: 链接:https://www.luogu.com.cn/problem/P1435 观察到:在里面插入字符不会影响外面的配对 所以以dp[i][j]记录字符串s下标从i到j变化到回文串步数,那么递推公式: if(s[i] == s[j])dp[i][j] = dp[i+1][j-1]; el 阅读全文
posted @ 2024-04-05 21:10 WHUStar 阅读(69) 评论(0) 推荐(0)
摘要: 题目: 链接:https://www.luogu.com.cn/problem/P1833 知识点:二进制优化,完全背包 emm怎么说呢,还是被卡内存,所以自顶而下编程不好!还是用滚动数组好点 代码: #include<iostream> #include<vector> #include<algo 阅读全文
posted @ 2024-04-05 20:51 WHUStar 阅读(35) 评论(0) 推荐(0)
摘要: 题目: 链接:https://www.luogu.com.cn/problem/P4933 这题本来的思路大体上是对的,就是根据已有的往后面推就行: 以i号元素结尾,公差为j的等差数列的数量 = 遍历k∈[1,i-1],dp[k][j]+1的和。 和这个大佬想的差不多,不过刚开始有点细节错误qAq 阅读全文
posted @ 2024-04-05 19:39 WHUStar 阅读(57) 评论(0) 推荐(0)
摘要: 题目: 链接:https://www.luogu.com.cn/problem/P2285 这题感觉如果想不到递推关系可能会很麻烦,因为我之前想到的关系就是用dp存:包含三个维度:times,x,y,即dp[times][x][y]来存,然后递推。 但是如果把dp看作是以p结尾的抓到的耗子数量时就会 阅读全文
posted @ 2024-04-05 14:33 WHUStar 阅读(19) 评论(0) 推荐(0)
摘要: 链接:https://www.luogu.com.cn/problem/P1020 这个题目一分为二: 首先就是LIS:改下,改成最长不升子序列,复杂度:nlogn;然后用vector的贪心,复杂度:n^2(这里似乎可以二分降到nlogn,不过反正过了OwO!) 被这个输入卡的好难受,建议用getl 阅读全文
posted @ 2024-04-05 11:35 WHUStar 阅读(164) 评论(0) 推荐(0)
摘要: 题面: 回顾下最长公共子序列: if(a[i]!=b[j]) dp[i][j] = max(dp[i-1][j],dp[i][j-1]); else dp[i][j] = dp[i-1][j-1] + 1; 复杂度为O(n^2) 但是这题不行,数据卡到了1e5,所以应该再次观察: 注意到是两个全排列 阅读全文
posted @ 2024-04-05 10:12 WHUStar 阅读(29) 评论(0) 推荐(0)
摘要: 参考链接:https://blog.csdn.net/lxt_Lucia/article/details/81206439 #include<iostream> #include<vector> #include<algorithm> #include<math.h> #include<sstrea 阅读全文
posted @ 2024-04-05 09:55 WHUStar 阅读(17) 评论(0) 推荐(0)