题目传送门 /* 题意:对于长度为x的子序列,每个序列存放为最小值,输出长度为x的子序列的最大值 set+线段树:线段树每个结点存放长度为rt的最大值,更新:先升序排序,逐个添加到set中 查找左右相邻的位置,更新长度为r - l - 1的最大值,感觉线段树结构体封装不错! 详细解释:http://blog.csdn.net/u010660276/article/details/46045777 其实还有其他解法,先掌握这种:) */ #include <cstdio> #include &l…
B. Mike and Feet Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/547/problem/B Description Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standi…
题意 n个值代表n个熊的高度 对于size为x的group strength值为这个group(连续的几个熊)中熊的最小的height值 对于x(1<=x<=n) 求出最大的strength值 http://codeforces.com/contest/548/problem/D 思路 我们把每个数作为最小值能最远向左和右用单调栈处理出来,那么可以发现对于x长度的所有group,某个数延伸的区间长度如果大于等于x,则这个数对答案有贡献. 对于样例,我们处理出来后可以观察发现确有此规律: 然后就…
D. Mike and Feet time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are…
D. Mike and Feet time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are…
Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high. A group of bears…
题目传送门 /* 数论/暴力:找出第一次到a1,a2的次数,再找到完整周期p1,p2,然后以2*m为范围 t1,t2为各自起点开始“赛跑”,谁落后谁加一个周期,等到t1 == t2结束 详细解释:http://blog.csdn.net/u014357885/article/details/46044287 */ #include <cstdio> #include <algorithm> #include <cstring> #include <iostream…
题目传送门 /* 暴力:每次更新该行的num[],然后暴力找出最优解就可以了:) */ #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <string> using namespace std; ; const int INF = 0x3f3f3f3f; int a[MAXN][MAXN]; int num[MAXN];…
题目传送门 /* 字符串处理:回文串是串联的,一个一个判断 */ #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <string> using namespace std; ; const int INF = 0x3f3f3f3f; char s[MAXN]; bool check(int x, int y) { for…
题目传送门 /* 线段树的单点更新:有一个交叉更新,若rank=1,or:rank=0,xor 详细解释:http://www.xuebuyuan.com/1154895.html */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <string> #include <cmath> #include <…