
AcWing算法基础
「已注销」
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
卡特兰数
欢迎来访首先看一下卡特兰数。若一个数列hnh_nhn满足:hn=∑i=0n−1hi⋅hn−1−ih_n = \sum_{i=0}^{n-1}h_i \cdot h_{n-1-i}hn=i=0∑n−1hi⋅hn−1−i则称hnh_nhn为卡特兰数列。还有一种形式若:hn=C2nnn+1h_n = \frac{C_{2n}^n}{n+1}hn=n+1C2nn也称hnh_n...原创 2020-04-20 20:47:05 · 425 阅读 · 0 评论 -
贪心 区间选点
题目题目链接分析做法:将所有区间按照右端点排序,遍历所有的区间,如果区间的左端点严格大于上一次选的点则答案+1,否则跳过该区间。证明:假设最优解的个数为ans,以这种做法选出点的个数为cnt。(证明两个数a,b相等,可以分别证明:a >= b,a <= b)1 证明ans <= cnt:ans为最优解,cnt为一种解,所以ans显然是小于等于cnt的。2 证明an...原创 2020-04-02 18:44:38 · 247 阅读 · 0 评论 -
合唱队型
题目题目链接在最长上升子序列问题中,朴素做法(这道题数据范围较小朴素算法也能过)中记录的是f[i]中的i是最大值的位置,这道题可以记录拐点的位置,左右分别为LIS问题,一个从左往右,一个从右往左。代码#include <iostream>#include <cstdio>#include <cstring>#include <algorith...原创 2020-02-28 10:00:32 · 208 阅读 · 0 评论 -
最长上升子序列模型(LIS)
题目链接,O(N2)O(N^2)O(N2)能过。题目链接,O(NlogN)O(N\log N)O(NlogN)能过。O(N2)O(N^2)O(N2)做法DP:f[i]表示,以第i个数结尾的最长子序列的集合的最大值。#include <iostream>#include <cstdio>#include <cstring>#include <...原创 2020-02-28 09:59:22 · 228 阅读 · 0 评论 -
AcWing789.数的范围
题目链接#include<iostream>using namespace std;const int N = 100010;int q[N];int n, m;int main(){ cin >> n >> m; for (int i = 0; i < n; i++) scanf("%d", &q[i]); while (...原创 2020-02-28 01:09:55 · 306 阅读 · 0 评论