自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(126)
  • 收藏
  • 关注

转载 二叉树的一个小性质

很明显,已知一棵二叉树的前序遍历和后序遍历,判断中序遍历时,其可能性只与没有兄弟节点的叶节点的位置有关。假设没有兄弟节点的叶节点共有n个,则可能性边有2^n个。(就不证明了)那么,如何计算n的值呢?下面有一个性质:一棵二叉树的前序遍历a1a2a3...ai和后序遍历b1b2b3...bi有一种关系:没有兄弟节点的叶节点的根 在a序列下标为i, 在b序列下标为j则有  a[i

2015-09-19 00:47:06 390

转载 矩阵快速幂和矩阵的乘法模板

//http://blog.csdn.net/rowanhaoa/article/details/39343769

2015-08-29 15:13:11 365

原创 KM算法板子2

//HDU2426//#include #include#include#includeusing namespace std;const int maxn=550;int visx[maxn],visy[maxn];int link[maxn];int lx[maxn],ly[maxn];int w[maxn][maxn];int slack[maxn];int lin

2015-08-21 19:28:52 479

转载 KM算法板子

//原题HDU2255/*其实在求最大 最小的时候只要用一个模板就行了,把边的权值去相反数即可得到另外一个.求结果的时候再去相反数即可*//*最大最小有一些地方不同。。*/#include #include#include#include//赤裸裸的模板啊。。const int maxn = 301;const int INF = (1<<31)-1;int w[maxn][

2015-08-18 00:48:16 513

原创 最小支配集合板子

//理论的东西 http://www.cnblogs.com/whatbeg/p/3776612.html//原题是POJ3659#include #include#include#includeusing namespace std;const int maxn=10000+10;int head[maxn];int next[2*maxn];int to[2*maxn]

2015-08-16 01:47:30 419

原创 CF316D

//大半夜的来写一发题解//教会我了怎么用vector的二分函数/(ㄒoㄒ)/~~//主要是dfs序啦。。。详细的可以在代码中感觉#include #include#include#include#includeusing namespace std;const int maxn=500000+10;int head[maxn];int to[maxn];int

2015-08-15 04:10:38 407

原创 博弈汇集

//今天到明天开始写博弈的题目。。。//博弈论的题目其实很久以前就写过挺多的,现在很多都忘了,写写题目复习下//巴什博弈

2015-08-13 16:51:07 376

原创 线段树懒惰写法板子

//对应d题目是HDU3577#include #include#include#includeusing namespace std;int k;const int maxn=1000000+10;int an[100000+10];struct tree{ int l; int r; int sum; int add;}node[4*ma

2015-08-13 02:36:49 711

原创 CODEVS1296

//treap 的简单应用#include #include#include#includeusing namespace std;typedef long long ll;int t1,t2;struct node{ node *ch[2]; int s,v,r; node(int v):v(v) { r=rand();

2015-08-07 16:33:30 334

原创 HDU5025

//状态压缩比较水的题。。可以用优先队列来写,来可以不用。。。如果是优先队列的话,那么实际上是可以看做迪斯特拉加堆优化寻找最短路//如果不是优先队列的话,可以看做是深搜了//写的时候犯了一个比较SB的错误#include #include#include#include#includeusing namespace std;const int maxn=105;cha

2015-08-07 03:40:06 664 1

原创 HDU5274

//我是无脑树链剖分的。。。过了快一个月了,终于靠自己把这道题A了..真是不容易呀。。。//无脑树链剖分加线段树#include #include#include#include#includeusing namespace std;#pragma comment(linker, "/STACK:102400000,102400000")const int maxn=1000

2015-08-04 04:00:49 369

原创 可合并堆。。。BZOJ1078

//写题最爽的还是对题意的分析呀//http://www.cppblog.com/MatoNo1/archive/2013/03/03/192131.html    //看了别人的分析才会写的#include #include#include#includeusing namespace std;const int maxn=105;int l[maxn],r[maxn

2015-08-04 01:59:41 793

原创 CF303DIV2 E 迪斯特拉加堆优化

//首先这道题是卡没有优化的迪斯特拉的。。。。然后就是数据的溢出问题。。。都开long long吧#include #include#include#include#include#includeusing namespace std;typedef long long ll;const int maxn=300000+10;const ll inf=999999999999

2015-08-03 15:45:51 389

原创 主席树。。板子HDU2665

//主席树真是。。。。。。简称函数式线段树。。。可以用来代替划分树。。。#include #include#include#includeusing namespace std;const int maxn=100000+10;int a[maxn],b[maxn];int sum[maxn<<5],lson[maxn<<5],rson[maxn<<5];int root[

2015-08-02 03:15:19 462

转载 树的重心

// http://fanhq666.blog.163.com/blog/static/81943426201172472943638/

2015-07-31 00:26:47 344

原创 HDU2852

//看到这道题的第一想法是treap....个人感觉treap应该也是可行了。网上流传的树状数组的方法也是二分暴力。。。#include #include#include#include#includeusing namespace std;const int maxn=100000+1;int sum[maxn];int lowbit(int x){ return

2015-07-30 05:15:37 516

转载 数组数组求第K小数

//还真没想到过树状数组还有这个功能。。。。。。。。。//原来作者地址。。ORZ   http://www.cnblogs.com/zgmf_x20a/archive/2008/11/15/1334109.html回顾树状数组的定义,注意到有如下两条性质:一,c[ans]=sum of A[ans-lowbit(ans)+1 ... ans];二,当ans=2^k时, c[

2015-07-30 04:07:11 1118

原创 dinic 板子

#include #include#include#include#includeusing namespace std;const int maxn=99999;const int inf=999999999;int to[maxn];int head[maxn];int next[maxn];int value[maxn];int tot;int src,sink;

2015-07-26 15:30:27 428

转载 treap 模板

#include#include#include#includeusing namespace std;struct Node{ Node *ch[2]; int r,v,s; Node(int v):v(v) { r=rand(); s=1; ch[0]=ch[1]=NULL; } vo

2015-07-24 20:52:34 238

原创 复习以前写过的知识点

//自己很多东西以前都写过,现在很多都忘了;篇博客就全当复习吧

2015-07-22 13:29:19 338

原创 bzoj2819

/还是树链剖分裸题。。。。。。#include#include#define MAXN 500005using namespace std;long father[MAXN][21];long dep[MAXN];long stack[MAXN*3];long top=0;long head[MAXN];long p[MAXN*2];long next[MAXN*2];long

2015-07-20 15:40:28 407

原创 树链剖分模板bzoj1036

#include #include#include#include#includeusing namespace std;const int maxn=30000+10;int head[maxn];int next[2*maxn];int to[2*maxn];int tot;int idx;void init(){    tot=0;

2015-07-20 15:38:51 261

原创 bestcoder48 第二题

//把两个不认识的人互相连边,在判断下有没有环,就OK 了;#include #include#include#include#includeusing namespace std;const int maxn=100000+10;vectormap1[maxn];int n;int visit[maxn];int sum[2];void init(){ for

2015-07-20 15:36:02 285

转载 LCA倍增模板

//别人的模板:http://www.tuicool.com/articles/N7jQV32

2015-07-14 16:30:54 479

原创 HDU3078

//LCA+排序//用的是倍增的在线算法。。。。#include #include#include#include#includeusing namespace std;const int maxn=80000+10;int val[maxn];int temp[maxn];struct node{ int from; int to; int

2015-07-14 16:13:39 698

原创 百度之星初赛第二场1005

实质上是求最长LIS;a[0]=#include #include#include#includeusing namespace std;int a[100050];int dp[100050];int len=0;int lis(int n){ int cnt=0; for(int i=0;i<n;i++) { int t=upp

2015-06-01 21:58:13 486

原创 五边形型数

1:一个讲解的很详细的五边型数的博客http://blog.csdn.net/zhoufenqin/article/details/9821617;2:题目;hdu4651,最简单的五边形数,母函数应该也可以做(N^3),,五边形数是(N^1.5);   HDU4658,5230;变形版;HDU5230的代码#include#include#include#include#

2015-05-21 23:35:24 757

原创 HDU2473 并查集的删除

并不是真正的删除,而是把删除的点连到了虚根#include#include#include#includeusing namespace std;const int maxnum=1100010;int fa[maxnum];int temp[maxnum];int mark[maxnum];int n,m,w;void init(){ int i; fo

2015-05-13 22:45:10 475

原创 并查集小结

1:基础并查集HDU1232HDU1272HDU3371 最小生成树HDU3172  字典树加并查集,,map的运用HDU3080  最小生成树HDU 2960  有一个坑点就是自己不能和自己重组2 带权并查集HDU3234   很好的一道题,用到了异或运算的规律;HDU3461  这道题,,我感觉自己还是不是很理解。。HDU3047  带权并查集 。。

2015-05-13 22:41:16 426

原创 hdu2419

参考了大牛的代码和想法。这道题的主要思路其实就是逆序思维;E这个删除操作,如果是逆序的话就是增加操作了;这样的话,那么整道题就回到了我们熟悉的普通的并查集了;这道题算不上难,但是想法一定要想通#include #include#include#include#include#includeusing namespace std;const int maxnum=200

2015-05-06 08:52:53 413

原创 AC自动机

http://acm.uestc.edu.cn/bbs/read.php?tid=4294写了个入门的模板题,HDU2222;#include #include#include#include#includeusing namespace std;struct node{ node *fail,*s[27]; int w;}*head;char t

2015-04-08 02:48:02 302

原创 线段树的一些题和对应的做法

HDU3627:这题主要是线段树加离散化,然后我们只要保存在一个区间内最大的Y值,然后在线更新;HDU3333;这道题是线段树加离线;HDU3911,这道题刚开始见到的时候觉的想法很奇特,主要是要保存6个值,从左边开始连续的0和1,和从右边开始连续的0和1;和在这个区间内连续的1和0 的最多的数量;HDU4366:这道题因为是树形关系。所以我们要先通过一个dfs把他们一一对应到一个数组

2015-03-03 01:52:21 337

原创 CF292C

感觉还是蛮有趣的一道题的,我刚开始还准备用递归来写,但是觉的太麻烦,看了下别人的,才发现原来这么简单。。。。。。。。在仔细想一想,确实就是这么简单#include #include#include#includeusing namespace std;int a[105];char str[18];int main(){ int n; while(scanf("

2015-02-25 17:26:06 515

原创 后缀数组的一些问题

1:求重复次数不小于K 的最长不重叠子串;这种题的思路解法是利用height数组的来分组,另外在增加一个queue数组来对每个分组里面的数组进行排序,在加以判断,另外需要看下N的范围大小,如果n》=10000话最好还是用DC3构造法,如果不是的话可以用倍增法,例题见hdu28902:求有多少子串重复次数大于2,且不重叠,还是一样利用height数组来分组在每次分组完毕的时候判断一下最大值和

2015-02-24 15:11:19 461

原创 hdu2890

//这题貌似只能用DC3构造法。因为N实在是太大了//WA了很多发,蛋疼//http://www.acmerblog.com/hdu-2890-longest-repeated-subsequence-4533.html#include #include #include #include #include using namespace std; const

2015-02-23 21:18:22 476

原创 HDU3518

//具体的文章分析可以看这个http://www.acmerblog.com/hdu-3518-boring-counting-6479.html#include #include#includeusing namespace std;const int maxn=1100;int wa[maxn],wb[maxn],wsf[maxn],wv[maxn],sa[maxn];int

2015-02-21 17:40:09 656

原创 DP+矩阵连乘

//这道题蛮好的。http://www.acmerblog.com/hdu-3658-how-many-words-6619.html#include #include#include#includeusing namespace std;#define ll __int64const int mod=1000000007;struct matrix{ ll f[5

2015-02-16 23:25:47 402

转载 C++中 模板Template的使用

//原文地址:http://blog.sina.com.cn/s/blog_74a271040100tkmj.html1、在c++Template中很多地方都用到了typename与class这两个关键字,而且好像可以替换,是不是这两个关键字完全一样呢?答:class用于定义类,在模板引入c++后,最初定义模板的方法为:template,这里class关键字表明T是一个类型,后

2015-02-14 17:13:29 1026

转载 POJ2217

//是看了别人的代码才AC的。我的代码是有问题的先 上我的代码#include #include#includeusing namespace std;const int maxn=10000*2+20;int wa[maxn],wb[maxn],wsf[maxn],wv[maxn],sa[maxn];int rank[maxn],height[maxn],s[maxn];c

2015-02-10 20:39:19 404

原创 la4513

//刘汝佳书上的用hash来写的,感觉有点拼人品呀,和X的取值的关系很大的#include #include#include#includeusing namespace std;const int maxn=40005;const int x=99;int rank[maxn];unsigned long long h[maxn],xp[maxn],hash[maxn];i

2015-02-10 00:31:22 678

空空如也

空空如也

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

TA关注的人

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