自定义博客皮肤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!

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

原创 环上k划分的和的gcd的最大值【gcd基本性质的利用】

今早看到的题,想了下会做了,但是觉得这题挺有意思的,于是打算写一下做法。本题利用了gcd的基本性质:更相减损法以及结合律,平时做gcd的题基本没用到过这两性质,而本题对这性质进行了充分利用。思路: 首先我们考虑给一个序列,我们该怎么做。 令f[i]=a[1]+a[2]+…+a[i]。 我们考虑序列的一个k+1划分f[x1],f[x2]-f[x1],f[x3]-f[x2],…,f[n]-f[xk

2016-10-31 20:59:17 2247

原创 【codeforces】gym 101138 K. The World of Trains【前缀和优化dp】

题目链接:K. The World of Trains记录一个横着的前缀dp和以及斜着的前缀dp,复杂度O(n2)O(n^2)#include <bits/stdc++.h>using namespace std ;typedef pair < int , int > pii ;typedef long long LL ;#define clr( a , x ) memset ( a , x ,

2016-10-31 19:09:52 966

原创 【Tsinsen】1228 飞飞侠【并查集优化最短路】

题目链接:A1228. 飞飞侠#include <bits/stdc++.h>using namespace std ;typedef long long LL ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN = 155 ;const LL INF = 1e18 ;struct Node { LL dis ;

2016-10-31 19:04:11 845

原创 【POJ】2449 Remmarguts' Date【k短路】

题目链接:Remmarguts’ Datek短路模板题,用这题验证了我可持久化左偏树的正确性。#include <stdio.h>#include <vector>#include <queue>#include <algorithm>using namespace std ;typedef long long LL ;typedef pair < int , int > pii ;ty

2016-10-31 15:59:36 877

原创 【HDU】5960 Subsequence 【可持久化左偏树维护K短路】

题目链接:Subsequence吐槽,先是对着定义yy了可持久化二项堆,然后发现不好搞这个k短路,然后找了左偏树的定义,对着yy了20分钟写出了可持久化左偏树,然后过了poj2449后就1A了这个题。#include <stdio.h>#include <vector>#include <queue>#include <algorithm>using namespace std ;typed

2016-10-31 15:56:36 2756

原创 可持久化二项堆

namespace Binomial_Heap { struct Node { int c[2] , x ; LL val ; } T[MAXN * 200] ; struct Heap { int n ; pii rt[BLOCK] ; Heap () : n ( 0 ) {}

2016-10-31 13:55:27 730

原创 【HDU】5957 Query on a graph【分类讨论+bfs序线段树】

题目链接:Query on a graph水题#include <bits/stdc++.h>using namespace std ;typedef long long LL ;typedef pair < int , int > pii ;typedef unsigned long long ULL ;#define clr( a , x ) memset ( a , x , sizeof

2016-10-30 17:53:25 1286

原创 【UVALive】6776 2014WorldFinal G Metal Processing Plant【2-sat——bitset优化kosaraju求scc】

题目链接:Metal Processing Plantbitset优化kosaraju,复杂度O(n^2/64),总复杂度O(n^4/64)。#include <bits/stdc++.h>using namespace std ;typedef long long LL ;typedef pair < int , int > pii ;typedef unsigned long long U

2016-10-27 19:05:02 863

原创 【BZOJ】4643 卡常大水题【bitset优化bfs】

题目链接:卡常大水题#include <bits/stdc++.h>using namespace std ;typedef long long LL ;typedef pair < int , int > pii ;typedef unsigned int UI ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN =

2016-10-26 17:41:33 1144

原创 【HDU】5899 oasis in desert 【二分匹配】

题目链接:oasis in desert#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 = 505 ;const int

2016-10-24 20:45:00 581

原创 【HDU】5905 Black White Tree【树dp,枚举子树,对于一个a,其对应的可行b一定是一个连续区间】

题目链接:Black White Tree枚举子树,对于一个a,其对应的可行b一定是一个连续区间。#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 )con

2016-10-24 19:36:17 681

原创 【HDU】5549 Walk Around The Campsite【极角排序+set+最短路dp】

题目链接:Walk Around The Campsite要知道多边形的边只会在端点相交。则如果以一个点为原点,作射线,然后旋转,那么遇到边的左端点我们往set插入线段,遇到边的右端点我们删除线段,那么任意时刻在set中的线段和射线的交点到原点的距离的大小关系是相对不变的。那么我们就可以通过动态维护set的操作符’<’动态维护线段距离原点的远近了。 接下来就很简单了,枚举原点,然后极角排序,然后转

2016-10-23 22:23:12 1503

原创 【UOJ】176 新年的繁荣【多路增广生成树】

题目链接: 新年的繁荣#include <bits/stdc++.h>using namespace std ;typedef pair < int , int > pii ;typedef long long LL ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN = 100005 ;struct Seg {

2016-10-17 19:14:15 1058

原创 【HDU】5817 Ice Walls【极角排序+树状数组+最短路】

题目链接:Ice Walls#include <bits/stdc++.h>using namespace std ;typedef long long LL ;typedef pair < double , int > pii ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN = 1005 ;const doubl

2016-10-17 17:10:33 522

原创 【51nod】1291 Farmer 【求n*m的矩形内全1的i*j的矩形个数】【dp】

题目链接:【51nod】1291 Farmer去年做的题,一直没有放出来,单调栈,O(N^2)。O(N^2logN)也能过。#include <bits/stdc++.h>using namespace std ;#define clr( a , x ) memset ( a , x , sizeof a )const int MAXN = 1005 ;char s[MAXN] ;int U[M

2016-10-13 14:52:09 1494

原创 【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 892 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 1162 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 811

原创 【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 820

原创 【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 673

原创 【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 491

原创 【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 803

原创 【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 508

原创 【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 720

原创 【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 463

原创 【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 786

原创 【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 1056

原创 【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 487

原创 【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 584

原创 【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 509

原创 【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 568

原创 【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 507

原创 【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 815

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

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

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

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

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

2016-10-08 11:08:31 1384

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

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

2016-10-08 11:00:11 1901

原创 【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 1203

原创 【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 901

原创 【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 894

并查集分类1

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

2014-03-14

空空如也

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

TA关注的人

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