摘要: 这个题其实有O(n)的算法,不过还是用线段树做了一遍,还写了个自认为不错的pushalldown函数,哈哈。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int N = 100001; 7 int ans... 阅读全文
posted @ 2015-07-30 23:06 hxy_has_been_used 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 线段树在解决区间合并问题上还是很强力的,每个结点维护三个值:maxl, maxr, maxn,然后合并操作见pushup函数。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int N = 50001; 7... 阅读全文
posted @ 2015-07-30 22:25 hxy_has_been_used 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 等差和等比各扫一遍即可。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 const int N = 1000000; 9 const double eps = 1e-8;... 阅读全文
posted @ 2015-07-30 19:52 hxy_has_been_used 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 下午比赛的时候写搓了,晚上重写一次就过了,o(╯□╰)o。思路:按照字典序贪心,用线段树来维护区间最值,用set来维护求出答案的封闭区间。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7... 阅读全文
posted @ 2015-07-30 19:37 hxy_has_been_used 阅读(270) 评论(0) 推荐(0) 编辑
摘要: 其实问题可以转化为:一堆数中有若干个1,若干个2,若干个3,...,若干个n,问是否存在一种排列的方式使得相邻的两个数不同,转化完以后问题就简单了。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 typedef lon... 阅读全文
posted @ 2015-07-30 10:46 hxy_has_been_used 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 很容易可以想到状态转移方程: dp[i] = segma: dp[j] ( j 2 #include 3 #include 4 #include 5 using namespace std; 6 7 typedef long long ll; 8 const int N = 100001... 阅读全文
posted @ 2015-07-30 09:49 hxy_has_been_used 阅读(142) 评论(0) 推荐(0) 编辑