跳跃式LIS(nlogn),在普通的转移基础上增加一种可以跨越一段距离的转移,用一颗新的树状数组维护,同时,我们还要维护跨越完一次后面的转移,所以我用了3颗树状数组.. 比赛的时候一句话位置写错了,然后就...雪崩 呆马: #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <vector> #include <algorith…
在线求第k大,第一次用二分+树状数组写...比赛的时候分治啊,splay啊,主席树啊换来换去,然而以前为什么不知道可以这么写... #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> #include <vector> #include <set> #define inf 1000000…
HDU 5489 Removed Interval 题意: 求序列中切掉连续的L长度后的最长上升序列 思路: 从前到后求一遍LIS,从后往前求一遍LDS,然后枚举切开的位置i,用线段树维护区间最大值,在i~n中找到第一个比a[i - L]大的位置k,用LIS[i - L] + LDS[k]更新答案. 代码 #include <iostream> #include <cstdio> #include <fstream> #include <algorithm>…
HDU 5492 Find a path 题意:给你一个矩阵求一个路径使得 最小. 思路: 方法一:数据特别小,直接枚举权值和(n + m - 1) * aver,更新答案. 方法二:用f[i][j][k]表示到达[i,j]是权值和为k时平方和的最大值,转移方程就是 f[i][j][k] = min(f[i][j][k], min(f[i - 1][j][k - a[i][j]] + sqr(a[i][j]), f[i][j - 1][k - a[i][j]] + sqr(a[i][j])));…
BFS+链表 代码改自某博客 #include<stdio.h> #include<iostream> #include<algorithm> #include<math.h> #include<string.h> #include<string> #include<map> #include<set> #include<vector> #include<queue> using nam…
先贴四份矩阵快速幂的模板:http://www.cnblogs.com/shangyu/p/3620803.html http://www.cppblog.com/acronix/archive/2010/08/23/124470.aspx?opt=admin http://www.cnblogs.com/vongang/archive/2012/04/01/2429015.html http://www.cnblogs.com/yan-boy/archive/2012/11/29/279529…
题目链接 Problem Description Uncle Mao is a wonderful ACMER. One day he met an easy problem, but Uncle Mao was so lazy that he left the problem to you. I hope you can give him a solution.Given a string s, we define a substring that happens exactly k time…
题目链接 Problem Description Now there are n gems, each of which has its own value. Alice and Bob play a game with these n gems.They place the gems in a row and decide to take turns to take gems from left to right. Alice goes first and takes 1 or 2 gems…
给出的数据1e12规模,常规判点是否在圆范围内肯定要用到半径,求得过程中无法避免溢出,因此用JAVA自带的浮点大数运算,和个ZZ一样比赛中eclipse出现问题,而且太久没写JAVA语法都不清楚变量忘了申请空间/构造,还不知道为什么写不了类/函数,一个一个把运算符改成JAVA大数对象封装的函数,括号看的头疼,太傻了,应该交给IDE正常的队友写的,而且也没什么难度,JAVA大数还不用考虑什么精度,怎么简单怎么来. import java.io.*; import java.math.*; impo…
Sparse Graph Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 928    Accepted Submission(s): 312 Problem Description In graph theory, the complement of a graph G is a graph H on the same verti…