Codeforces Zip-line 650D 345Div1D(LIS)】的更多相关文章

传送门 大意:给出一个序列,求修改一个数过后的最长上升子序列. 思路:可以用主席树在线搞,也可以用树状数组离线搞,明显后者好写得多.我们首先读取所有的询问,然后就把询问绑在给出的位置,然后我们正向做一遍LIS,反向做一遍LDS,然后就可以解决这个问题了. #include <cstdio> #include <algorithm> #include <vector> #define MAXN 400005 using namespace std; inline void…
http://codeforces.com/gym/101246/problem/H 题意:在二维平面上有n个点,从最左下角的点出发,每次走只能走在当前的点的右上角的点(xj > xi, yj > yi).问在走了最长路径的前提下有哪些点是可能被走到的,哪些点是必须被走到的. 思路:比赛的时候以为是图论的题目,结果可以转化为LIS求解,太强啦. 首先直接对坐标按照x从小到大进行排序,如果x相同,y从大到小排序.为什么y是从大到小排序呢?因为在后面我们只看y的大小来做LIS,即通过排序消掉了x维…
枚举根+dfs 它可以活 , 我不知道有什么解决的办法是积极的 ...... F. Treeland Tour time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output The "Road Accident" band is planning an unprecedented tour around Treeland. The…
https://codeforces.com/contest/1304/problem/D #include<bits/stdc++.h> using namespace std; void solve(){ int n; string s; cin>>n; cin>>s; int Min[n]; int t = n; ;i<s.length();i++){ ,indx = i; if(s[i] == '<'){ while(s[i]=='<'){ l…
根据题目,我们可以找最短的LIS和最长的LIS,找最短LIS时,可以将每一个increase序列分成一组,从左到右将最大的还未选择的数字填写进去,不同组之间一定不会存在s[i]<s[j]的情况,保证满足题意,找最长LIS,可以找补集,将每个decrease序列分成一组,找到后取反即可 #include<bits/stdc++.h> using namespace std; #define lowbit(x) ((x)&(-x)) typedef long long LL; vec…
ax+by+c=0可以转化为ax+by=-c: 可以用扩展欧几里德算法来求ax1+by1=gcd(a,b)来求出x1,y1 此时gcd(a,b)不一定等于-c,假设-c=gcd(a,b)*z,可得z=-c/gcd(a,b); 则ax+by=-c <==> (ax1+by1)*z=gcd(a,b)z; <==> ax1*z+bx2*z=gcd(a,b)z; 因此可以得知x与x1的关系,y与y1的关系: x=x1*z,y = y1*z(z上面已经求出来了) #include<st…
题意:n个圆柱形蛋糕,给你半径 r 和高度 h,一个蛋糕只能放在一个体积比它小而且序号小于它的蛋糕上面,问你这样形成的上升序列中,体积和最大是多少 分析:根据他们的体积进行离散化,然后建树状数组,按照序号进行循环,每次查询体积比它小的蛋糕形成的最大体积 注:因为是按照序号进行循环,所以序号一定是严格小于它的,时间复杂度O(nlogn) #include <iostream> #include <cstdio> #include <algorithm> using nam…
Vasya has decided to build a zip-line on trees of a nearby forest. He wants the line to be as long as possible but he doesn't remember exactly the heights of all trees in the forest. He is sure that he remembers correct heights of all trees except, p…
D. Zip-line 题目连接: http://www.codeforces.com/contest/650/problem/D Description Vasya has decided to build a zip-line on trees of a nearby forest. He wants the line to be as long as possible but he doesn't remember exactly the heights of all trees in t…
Vasya has decided to build a zip-line on trees of a nearby forest. He wants the line to be as long as possible but he doesn't remember exactly the heights of all trees in the forest. He is sure that he remembers correct heights of all trees except, p…