自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

poursoul

仔细读题!不要偷懒!多看Clarification!

  • 博客(718)
  • 资源 (1)
  • 收藏
  • 关注

原创 【HDU】5129 Yong Zheng's Death【AC自动机+dp】

题目链接:Yong Zheng’s Death#include <bits/stdc++.h>using namespace std ;typedef long long LL ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN = 300005 ;int nxt[MAXN][26] ;int word[MAXN] ;

2016-10-11 14:35:48 886 1

原创 【HDU】5121 Just A Mistake【容斥+dp】

题目链接:Just A Mistake考虑先枚举根,求根必选的排列数,这样可以算出根对答案的贡献。然后,设dp[i][j]表示以i为根的子树,i排在第j位且i必选的方案数。考虑子树v,如果v的位置在i的前面,那么v必须不选,那么我们把他减掉;如果v的位置在i后面,那样在我们选了i以后自然不会选v。然后就是对两个排列求并的方案数,这个和【HDU】5789 Permutation一个道理,都是枚举一个排

2016-10-10 18:47:15 1127 1

原创 【HDU】5604 merge【set练习题】

题目链接:merge#include <stdio.h>#include <string.h>#include <set>#include <algorithm>using namespace std ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN = 300005 ;set < int > s[MAXN] ;

2016-10-08 20:12:55 801

原创 【HDU】5736 Call It What You Want【暴力+dp】

题目链接:Call It What You Want暴力枚举经过的顺序,然后起点终点在一个子树的做个dp即可。#include <bits/stdc++.h>using namespace std ;typedef long long LL ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN = 100005 ;cons

2016-10-08 20:04:14 806

原创 【HDU】5740 Glorious Brilliance【费用流】

题目链接:Glorious Brilliance#include <bits/stdc++.h>using namespace std ;typedef long long LL ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN = 505 ;const int MAXE = 2000005 ;const int I

2016-10-08 20:01:02 656

原创 【HDU】5743 Join The Future【dp】

题目链接:Join The Future并查集压缩相等的点,发现最多只会有20个大于1的联通块,状压dp即可#include <bits/stdc++.h>using namespace std ;typedef long long LL ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN = 42 ;const int

2016-10-08 19:59:02 474

原创 【HDU】5746 Memento Mori【双指针】

题目链接:Memento Mori#include <bits/stdc++.h>using namespace std ;typedef long long LL ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN = 2005 ;struct Node { int x , y ; Node () {}

2016-10-08 19:54:59 776

原创 【HDU】5751 Eades【FFT】

题目链接:Eades#include <stdio.h>#include <string.h>#include <math.h>#include <vector>#include <algorithm>using namespace std ;typedef long long LL ;typedef pair < int , int > pii ;#define clr( a , x

2016-10-08 19:48:22 493

原创 【HDU】5757 Product Bo【分情况讨论+队列】

题目链接:Product Bo思想很好,挺有趣的题,在床上突然会做的。#include <bits/stdc++.h>using namespace std ;typedef long long LL ;typedef pair < int , int > pii ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN =

2016-10-08 13:10:02 711

原创 【HDU】5759 Gardener Bo【线段树+lca+分类讨论】

题目链接:Gardener Bo分情况处理add操作即可。#include <stdio.h>#include <string.h>#include <math.h>#include <vector>#include <algorithm>using namespace std ;typedef unsigned int UI ;typedef pair < int , int > pi

2016-10-08 13:05:06 453

原创 【HDU】5766 Filling【轮廓线dp+burnside引理】

题目链接:Filling轮廓线dp出整个的,一半的,1/4的,然后用burnside引理去重。#include <bits/stdc++.h>using namespace std ;typedef long long LL ;typedef pair < int , int > pii ;#define clr( a , x ) memset ( a , x , sizeof a )const

2016-10-08 12:57:50 771

原创 【HDU】5771 Turn Game 【dp套dp】

题目链接:Turn Gamedp套dp。逐行dp,枚举每一行的状态,向下转移。状态即每一列上是否有列覆盖住这一行。#include <bits/stdc++.h>using namespace std ;typedef long long LL ;typedef vector < int > vi ;typedef map < LL , int > mpvi ;#define clr( a ,

2016-10-08 12:52:07 1014

原创 【HDU】5786 Interval【分类讨论+容斥】

题目链接:Interval#include <bits/stdc++.h>using namespace std ;typedef long long LL ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN = 80005 ;const int mod = 1e9 + 7 ;vector < int > fac[MAX

2016-10-08 12:46:18 479

原创 【HDU】5789 Permutation【dp】

题目链接:Permutation#include <bits/stdc++.h>using namespace std ;typedef long long LL ;typedef vector < int > vi ;typedef map < LL , int > mpvi ;#define clr( a , x ) memset ( a , x , sizeof a )const int

2016-10-08 12:42:23 570

原创 【HDU】5796 Magic Number【lca】

题目链接:Magic Number看懂题目,就知道怎么做#include <stdio.h>#include <vector>#include <string.h>#include <algorithm>using namespace std ;typedef long long LL ;typedef pair < int , int > pii ;#define clr( a , x

2016-10-08 12:38:35 495

原创 【HDU】5837 Robots【DP】

题目链接:Robots旋转45度坐标系,x’=x+y,y’=x-y,然后横纵坐标变成独立问题,接下来dp。#include <bits/stdc++.h>using namespace std ;typedef long long LL ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN = 205 ;const int

2016-10-08 11:54:11 557

原创 【HDU】5859 Captain is coding【优先队列贪心】

题目链接:Captain is coding二分Z用了多少次,然后枚举deadline小的用了多少Z,再优先队列模拟#include <bits/stdc++.h>using namespace std ;typedef long long LL ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN = 1005 ;stru

2016-10-08 11:44:57 497

原创 【HDU】5906 Square Revolution【后缀数组+RMQ求LCP+并查集+扫描线+树状数组】【求以某个点为开始或者结尾的最短AA形式串的长度】

题目链接:Square Revolution题意:求串s有多少个子串满足不存在形式为AA的前缀或后缀(其中A是一个字符串)。本质是求以某个点为起点或者终点的最短AA串的长度。求出这东西以后就可以询问离线+扫描线树状数组搞搞了。求最短AA串怎么求呢,我们枚举A的长度k,然后看i和i+k的lcp(最长公共前缀)和lcs(最长公共后缀)是否加起来大于等于k,是的话用他们更新一下被影响的每个点的信息(即以他

2016-10-08 11:36:36 801

原创 【HDU】5910 Advanced Traffic System【线段树+并查集】【数据结构模拟最短路】

题目链接:Advanced Traffic System建线段树,每个线段树节点存下包含这个区间的加边的信息。然后第一次取所有包含起点的加边区间,然后将这些信息标记为删除(以后遇到就删掉,保证复杂度),然后加上他们的边权,丢进优先队列里。然后从优先队列里取出最小的一个加边信息,将矩阵里所有的点去更新,更新方法和用起点更新的方法是一样的。考虑到每次枚举矩形内所有的点肯定复杂度不对,而且因为每个点只会被

2016-10-08 11:24:41 711 3

原创 【HDU】5928 Birthday Gift【极角排序+dp】

题目链接:Birthday Gift首先,最优解一定是一个凸包,但是接下来的算法不会显性利用到凸包的性质。 枚举每个点作为多边形最左侧的端点(然后删除他左侧的点,否则可能会错,我就因为这个问题错了好几发,虽然不知道什么情况,删了保证对),然后以这个点做极角排序,接下来dp[i][j]表示多边形上上个极角序最大的点是i,内部包含了j个点的最小周长,然后枚举下一个点就可以做到n^3转移(三角形内点的个

2016-10-08 11:08:31 1370

原创 【HDU】5930 GCD【暴力+线段树二分】

题目链接:GCD首先以每个点作为右端点的相同区间gcd的左端点构成一个区间,则这些区间最多只有log个。nlogn暴力预处理出每个gcd值的个数。 考虑修改第i个点值对所有gcd值的影响,影响的gcd值肯定是包含i的区间。把所有以i为右端点的gcd值区间取出来,i为左端点的也取出来,取的方法用线段树上二分(比较简单,就不细说了),然后左边和右边最多各logn个,所以logn*logn暴力更新就好了

2016-10-08 11:00:11 1853

原创 【HDU】5932.Backpack on Tree 【贪心+背包】

题目链接:Backpack on Tree每层,对价值除以花费的斜率从大到小排序,然后贪心到恰好大于询问的容量t,接下来开始dp。 设dp[i][j]表示贪心到第i个物品,取出里面花费为j的最小价值。dp2[i][j]表示斜率从小到大(即从右到左)取出花费为j的最大代价。 假设现在贪心得到的价值为t2(因为最大花费为5,所以t2-t<5),然后我枚举从贪心的解里面丢掉花费为x的最小价值dp[i]

2016-10-08 10:51:52 1183

原创 【codeforces】704D. Captain America 【上下界最小流】

题目链接:D. Captain America上下界最小流模板题,离散化建图跑即可。By No.baka, contest: Codeforces Round #366 (Div. 1), problem: (D) Captain America, Accepted, # #include <bits/stdc++.h>using namespace std ;#define clr( a ,

2016-10-08 10:23:16 895

原创 【codeforces】718D. Andrew and Chemistry 【树同构】

题目链接:D. Andrew and Chemistry树同构模板题,同构的儿子选一个走就好。#include <bits/stdc++.h>using namespace std ;typedef long long LL ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN = 100005 ;const int MA

2016-10-08 10:16:09 867

原创 玲珑杯#3 G 1043 - G. Quailty and Square Counter【线段树-卡常数】

题目链接:1043 - G. Quailty and Square Counter首先,x向x^2%2017建边,跑一跑找找规律,能发现环套树一共有14个,每个的环最大6,且在环上的点一共64个,且不在环上的点到环的常数最多5。知道这样的性质后,就简单了,区间平方直接暴力,区间赋值直接搞,暴力的话到某个区间为相同数时停止。其实上面都不是重点,大家都会,卡常才是最重要的,我从本地43s卡到11.6s,

2016-09-30 18:19:49 995

原创 【XTU】2016湘潭邀请赛 I Substring Query【AC自动机+分块】

时间复杂度O(NN−−√)O(N\sqrt N) 空间复杂度O(N)O(N)my   code:my~~~code:#include <bits/stdc++.h>using namespace std ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN = 100005 ;const int MAXQ = 10000

2016-06-12 15:02:14 1315

原创 【ZOJ】3942 Substring Counting【浙江ACM2016省赛G题】【填坑】

传送门:【ZOJ】3942 Substring Counting赛场上写了两个多小时没有过,回来后过了好久才肯补。结果写了4个多小时,还写了trie来对拍,调到电脑没电还没调好,第二天终于找到最后一个细节错,艰难的AC了。各种漏细节,没救了。(希哥说他这题定义是简单题,mdzz!)总之就分三种情况模拟,两边是00,两边是11,两边是01或10(01或10只要reverse下数组就能用同一种方法计算

2016-04-26 11:06:09 1496

原创 【FZU】Problem 2217 Taxi 【暴力状压dp】

传送门:【FZU】Problem 2217 Taximy   code:my~~~code:///*#include <stdio.h>#include <string.h>#include <algorithm>//*///#include <bits/stdc++.h>using namespace std ;typedef long long LL ;#define clr( a

2015-12-28 18:21:14 1151

原创 【Codeforces】280D k-Maximum Subsequence Sum【区间内k段最大和——线段树模拟费用流】

传送门:【Codeforces】280D k-Maximum Subsequence Sumkey word:取反my  code:my~~code:#include <stdio.h>#include <string.h>#include <vector>#include <algorithm>using namespace std ;typedef long long LL ;#defi

2015-12-28 12:26:26 1220

原创 【FZU】2208 cleaning again【模数质因数以3为众数的三进制NTT】

由Ak=A[0](w3kn)+wkn⋅A[1](w3kn)+w2kn⋅A[2](w3kn)A_{k}=A^{[0]}(w_n^{3k})+w_n^{k}\cdot A^{[1]}(w_n^{3k})+w_n^{2k}\cdot A^{[2]}(w_n^{3k}) 得yk=y[0]k+wkn⋅y[1]k+w2kn⋅y[2]ky_{k}=y_{k}^{[0]}+w_n^{k}\cdot y_{k}^{

2015-11-16 19:23:23 1543

原创 【BZOJ】4130: [PA2011]Kangaroos【KD树——最长连续1的子段长度】

传送门:【BZOJ】4130: [PA2011]Kangaroos【KD树】题意:给出一个长度为N(N≤5⋅104)N(N\leq 5\cdot 10^4)的区间序列。然后接下来M(M≤2⋅105)M(M\leq 2\cdot 10^5)个询问,每个询问给出一个区间[L,R][L,R],问区间序列中最长的连续子序列长度,使得连续子序列中每个区间和询问给出的区间存在交集。分析:将询问[L,R][L,R

2015-11-12 19:45:31 1348

原创 【BZOJ】4154: [Ipsc2015]Generating Synergy【KD树】

传送门:【BZOJ】4154: [Ipsc2015]Generating Synergy分析:以dfs序和深度为关键字,作为平面点,于是对于每个询问就是在平面上的矩形区域修改以及查询。my   code:my~~~code:#include <bits/stdc++.h>using namespace std ;typedef long long LL ;#define clr( a , x )

2015-11-12 14:15:59 1541

原创 【BZOJ】3616: War【KD树】

传送门:【BZOJ】3616: War【KD树】分析:建好树,对于每个塔,对他能打到的点打标记,这个用KD树+bitset打标记即可。所有标记打完后把标记下传,这样可以得到每个点在每一轮会被哪些塔打到,然后我们把所有同一阵营的或(位运算)起来,这样就知道每个阵营每一轮有多少的概率是完全完好的,然后pow一下累加到ans里,最后输出ans即可。复杂度O(NN−−√+N232)O(N\sqrt N +

2015-11-10 14:40:24 1096 2

原创 【HDU】2966 In case of failure【KD树】

传送门:【HDU】2966 In case of failure【KD树】题意:给平面图上N(1≤N≤105)N(1\leq N \leq 10^5)个点,对每个点,找到其他 欧几里德距离 离他最近的点,输出他们之间的距离。保证没有重点。这是本弱学习KDKD树做的第一题。本题做法网上很多,我就不详细说了。KDKD树在算法竞赛中主要用来做各种各样的平面区域查询,包含则累加直接返回,相交则继续递归,相离

2015-11-10 12:54:20 1666 4

原创 【HDU】5470 Typewriter 【后缀自动机+dp】

传送门:【HDU】5470 Typewritermy  code:my~~code:#include <bits/stdc++.h>using namespace std ;typedef long long LL ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN = 100005 ;const int N = 26

2015-09-29 22:20:29 1788 1

原创 【HDU】5421 Victor and String【回文树扩展——可左右添加字符的回文树】

传送门:【HDU】5421 Victor and String能维护左右最长回文的前提是要知道除了上一个节点表示的最长回文串能更新出新的本质不同的回文串外,其他节点都做不到(比赛的时候就是这个性质没想清楚,然后想了个O(N2)O(N^2)的做法……),这个可以YY一下,想清楚了就简单了,分别维护左右last指针,然后用一棵回文树实现这个过程,具体过程我就不多说了。my  code:my~~code:

2015-08-22 22:38:10 2009

原创 【HDU】5390 tree【线段树套字典树】

传送门:【HDU】5390 tree操作记得离线到每个线段树节点中,否则在线做,空间可能爆炸……my  code:my~~code:#pragma comment(linker, "/STACK:16777216")#include <stdio.h>#include <string.h>#include <stdlib.h>#include <vector>#include <algor

2015-08-13 22:28:53 1342

原创 【HDU】5383 Yu-Gi-Oh!【费用流】

传送门:【HDU】5383 Yu-Gi-Oh!my  code:my~~code:#include <stdio.h>#include <string.h>#include <vector>#include <algorithm>using namespace std ;typedef long long LL ;#define clr( a , x ) memset ( a , x , s

2015-08-13 21:16:01 1086

原创 【HDU】5370 Tree Maker 【树dp】

传送门:【HDU】5370 Tree Makermy  code:my~~code:#include <bits/stdc++.h>using namespace std ;typedef long long LL ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN = 505 ;const int mod = 1e9

2015-08-12 11:44:24 893

原创 【HDU】5367 digger【动态线段树】

传送门: 【HDU】5367 diggermy  code:my~~code:#include <stdio.h>#include <string.h>#include <algorithm>using namespace std ;typedef long long LL ;#define clr( a , x ) memset ( a , x , sizeof a )const int M

2015-08-08 22:58:43 1284

并查集分类1

大家尽管下载,并查集专题现在已经上传,尽请期待

2014-03-14

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除