摘要: 通道思路:每个数建个31位的树,处理好关系即可代码:#include #include #include using namespace std;const int N = 60007;const int BIT = 32;int n, m;int tot, s[N * BIT], a[N * BI... 阅读全文
posted @ 2015-10-24 15:45 mithrilhan 阅读(263) 评论(0) 推荐(0) 编辑
摘要: 题意:给你一个N*N的矩阵,不用算矩阵乘法,但是每次询问一个子矩形的第K小数思路:整体二分+二维树状数组二分询问的答案mid,将数值小等mid的全部插入二维树状数组然后查询每个矩阵内的元素个数,若数量>K-1则放左边,否则放右边继续向下分治,左边二分l-mid,右边mid-r代码:#include#... 阅读全文
posted @ 2015-10-11 22:32 mithrilhan 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 通道题意:有m个空间站组成一个环形的轨道,每个空间站属于n个国家之一。一次流星雨可以给一段连续的空间站带来同样数量的陨石样本。给出每个国家需要的陨石数量和流星雨的出现情况,问每个国家最快在多少次流星雨前就能收集到需要数量的陨石思路:分别二分算出答案即可代码:#include #include #in... 阅读全文
posted @ 2015-10-11 18:44 mithrilhan 阅读(220) 评论(0) 推荐(0) 编辑
摘要: 通道题意:给你n(1e5)个三元组、然后要你求这n个三元组的LIS。和这样LIS的方案数。一个三元祖a比另一个元祖b大的条件是ax>=bx,ay>=by,az>=bz思路:排序x去掉一维。然后我们要找到 y z。然后对于一个区间上,我们对y排序,但是在排序之前记录下此时的id排序之后,就能得到y的递... 阅读全文
posted @ 2015-10-10 19:05 mithrilhan 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 题意:维护一个W*W的矩阵,每次操作可以增加某格子的权值,或询问某子矩阵的总权值思路:CDQ模板题吧,点和矩形(4个点)都看成点,然后利用矩阵的前缀和可求出代码:#include #include #include #include using namespace std;const int max... 阅读全文
posted @ 2015-10-10 15:24 mithrilhan 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 题意:先给出n个点, 然后有m个操作, (1, x, y) 表示查询离(x, y)最近点的曼哈顿距离, (2, x, y) 表示插入点 (x, y).思路:. 距离点(x, y)最近的点和x的方位有四种, 左下左上右下右上, 然后只考虑一个方位, 另外的改变坐标即可. dis({x, y}, {x'... 阅读全文
posted @ 2015-10-10 15:16 mithrilhan 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 通道题意:计算C(n,0)+...C(n,n)思路:转化为LCM(1...n)/ n代码:#include #include using namespace std;typedef long long ll;const int N = 1000000+2;const ll MOD = (ll)1e9... 阅读全文
posted @ 2015-10-03 15:24 mithrilhan 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 通道思路:dp[i][j][k]:k步时,A到i行,B到j行的最大值代码:#include #include using namespace std;int maxPath(vector > &num) { const int m = num.size(); const int n = ... 阅读全文
posted @ 2015-10-02 20:24 mithrilhan 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 通道思路:可以发现这序列是一段上升一段下降的锯齿形。先考虑拿到所有正数,此时如果段数大于m,考虑怎么最小代价减少段的数量,从 负数和最小的开始合并?而且要考虑负数和超过正数和的情形,注意特殊情况是这段和为0时,并不需要合并,直接跳过。减小个数的方案是,要么这段大于0,去掉这个及左右2边,并合并,这样... 阅读全文
posted @ 2015-10-01 19:20 mithrilhan 阅读(628) 评论(0) 推荐(0) 编辑
摘要: 通道思路:连续上升,连续下降的值放到set里面,然后对于大于m的集合双向链表进行合并,合并肯定是找绝对值最小的合并。代码:#include #include #include #include using namespace std;typedef long long ll;const int N ... 阅读全文
posted @ 2015-10-01 15:35 mithrilhan 阅读(291) 评论(0) 推荐(0) 编辑
摘要: 通道思路:先求一下从第一位开始的到第i位的累加,4,-1,5,-2,-1,2,6,-2=>4386571311对这个累加的数列排个序,然后只要判断邻近的两个数是否可以组成序列,比如4和3就不可以,因为4>3而4对应下标为0,3对应为1。4和5就可以,然后相同的前缀和取id最小,一开始丢个(0,0)进... 阅读全文
posted @ 2015-10-01 12:34 mithrilhan 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 通道思路:dp[i]由dp[i-1]而来,统计小于a[i]的位置k,且dp[k]+1=dp[i]的所有个数即可。代码:#include #include #include using namespace std;typedef long long ll;template inline bool rd... 阅读全文
posted @ 2015-09-30 16:27 mithrilhan 阅读(455) 评论(1) 推荐(0) 编辑
摘要: 通道题意:最大周期串有多少个,子串不算。思路:建好SAM后,fail和next跳,删除前缀相同和后缀相同即可代码:#include #include #include #include #include #include using namespace std;const int MAX_N = 2... 阅读全文
posted @ 2015-09-27 19:55 mithrilhan 阅读(222) 评论(0) 推荐(0) 编辑
摘要: 通道题意:给出1字母树,询问一字符串是否出现在该树中思路:直接搜索剪枝,有人点分治?写了几发都T了。。有人会了教我?代码:#include #include #include using namespace std;struct Edge { int v, nxt; Edge () { ... 阅读全文
posted @ 2015-09-26 21:31 mithrilhan 阅读(269) 评论(0) 推荐(0) 编辑
摘要: 通道题意:0-9字符串,区间修改,区间询问是否d周期思路:直接暴力线段树,然后HASH修改和查询,卡HASH的话就双HASH。代码:#include#includetypedef long long ll;const int N = 100007;int n, m, k, lens;char s[N... 阅读全文
posted @ 2015-09-23 20:33 mithrilhan 阅读(291) 评论(0) 推荐(0) 编辑