自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 hdu 5236

2015上海邀请赛

2015-05-31 23:13:59 1195

转载 图论五百题

=============================以下是最小生成树+并查集======================================【HDU】1213 How Many Tables 基础并查集★1272 小希的迷宫 基础并查集★1325&&poj1308 Is It A Tree? 基础并查集★1856 More is better

2014-12-09 16:18:57 512

原创 FOJ 2014.3 有奖月赛

FOJ 2014.3 由于跑A区去面试的原因,这次比赛没参加,回来时已经四点多了,过了H题,然后D题交了一发,没考虑一个盟国只有一个国家的情况,wa了一次,之后就结束比赛了…具体说下每道题吧。 A. 文件系统  简单模拟题。 把题目意思理清楚就比较简单了。每个组给一个编号,并记录它的成员,然后对每个文件进行判断就可以了。(徐伟拿了一血!!) B. A s

2014-03-25 19:28:38 706 1

原创 后缀数组

// 倍增算法int wa[maxn],wb[maxn],wv[maxn],wss[maxn];int rank[maxn],height[maxn],sa[maxn];int cmp(int *r,int a,int b,int l){return r[a]==r[b]&&r[a+l]==r[b+l];}void da(int *r,int *sa,int n,int m){

2014-03-15 21:54:01 420

原创 LCA

// rmqvoid dfs(int u,int f,int d) { int tmp=++cnt; E[tmp]=u; L[++tot]=tmp; H[u]=tot; dis[u]=d; for(int i=0;i<vec[u].size();i++) { int v=vec[u][i].f; if(v!=f) {

2014-03-08 15:31:00 515

转载 splay

#include #include #include #include #define N 100001using namespace std;int n, a[N], b[N];int size, p[N], s[N], o[N], c[N][2];void update(int x){ s[x] = s[c[x][0]] + s[c[x][1]] + 1; o[x

2014-01-22 23:45:13 478

转载 sap

#include#define min(a,b) ((a)<(b)?(a):(b))const int MAX=2100000000,MAXn=200+9;int n,answer,g[MAXn][MAXn],d[MAXn],gap[MAXn],st=1,ed=n;int sap(int u,int flow){ if(u==ed) return flow; int res=fl

2013-10-27 22:53:48 547

转载 AC自动机数组写法

const int maxlen=110,kind=26;struct Trie{ int nt[maxlen][kind],fail[maxlen],end[maxlen]; int root,L; int newnode() { for(int i=0;i<kind;i++) nt[L][i]=-1; end[L++]=0; return L-1; } void

2013-09-26 16:40:04 1018

转载 manacher求最长回文子串

const int MAXN=110010;char Ma[MAXN*2];int Mp[MAXN*2];void Manacher(char s[],int len){ int l=0; Ma[l++]='$'; Ma[l++]='#'; for(int i=0;i<len;i++) { Ma[l++]=s[i]; Ma[l++]='#'; } Ma[l]=0;

2013-09-25 13:53:19 325

翻译 SBT

const int maxn=50010;const int INF=0x3f3f3f3f;struct SBT { int key,left,right,size; } tree[maxn]; int root,top; void left_rot(int &x) { int y = tree[x].right; tree[

2013-08-27 16:25:25 419

转载 高斯消元借模线性同余方程

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }int lcm(int a,int b) { return a/gcd(a,b)*b; }int a[maxn][maxn],x[maxn];int equ,var;int Gauss(){ int i,j,k,max_r,col; int LCM,tmp,ta,tb; fo

2013-08-18 14:23:18 533

原创 AC自动机

const int maxn=10000010,M=26;struct node{ int num; node *nt[M],*fail; void init() { num=0; for(int i=0;i<M;i++) nt[i]=NULL; fail=NULL; }}T[maxn];#define root Tint cnt;void insert(ch

2013-07-26 16:02:34 377

原创 FFT

#include#include#include#include#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;#define LL long long#define pi (acos(-1.0))

2013-07-26 14:12:48 418

转载 状压dp

1.每一行用一个二进制数表示, 有些二进制数是题目中不合法的状态,我们可以预处理出一行合法状态的个数,在递推的过程中复杂度就会大大降低。POJ 3254        Corn Fields        codePOJ 3311        Hie with the Pie         codeHDU 4539      郑厂长系列故事――排兵布阵      codeP

2013-07-20 01:18:42 387

原创 Pollard整数分解

#include#include#include#include#include#includeusing namespace std;//****************************************************************// Miller_Rabin 算法进行素数测试//速度快,而且可以判断 <2^63的数//******

2013-07-14 17:11:21 487

原创 miller素数测试

#define N 5LL random(LL n){ return (LL)((double)rand()/RAND_MAX*n+0.5);}LL multi(LL a,LL b,LL m) //(a*b)%m{ LL ans=0; while(b>0) { if(b&1) ans=(ans+a)%m; b>>=1; a=(a+a)%m; } return a

2013-07-14 15:54:19 382

原创 扩展KMP

#include#includeusing namespace std;const int MM=100005;int next[MM],extand[MM];char S[MM],T[MM];void GetNext(const char *T){ int len=strlen(T),a=0; next[0]=len; while(a<len-1 &&

2013-07-01 22:40:39 359

原创 动态树

#define NMax 10000struct node{ int key,mn,delta; int revmark; node *p,*l,*r; node(){}};struct DynamicTree{ node *nodes; int N; static void ini_node(node *p){ p->p=p->l=p->r=NULL; p->revm

2013-06-25 09:28:50 392

原创 KMP

void getpre(char *s){ int j=-1,i; p[0]=-1; int n=strlen(s); for(i=1;i<n;i++) { while(j>=0&&s[j+1]!=s[i]) j=p[j]; if(s[j+1]==s[i]) j++; p[i]=j; }}void kmp(){ int j=-1,i,n=strlen(sa),m

2013-06-21 23:14:53 488

原创 字典树

struct node{ bool flag; node *next[2]; node() { next[0]=next[1]=NULL; flag=false; }};void insert(node *&root ,string word){ if(root==NULL) root=new node(); node *p=root; for(int i=0;i

2013-06-09 11:58:59 447

原创 扩展欧几里得

struct eu{ int a,b,x,y,q; void extend_euclid(int a,int b) { if(b==0) { x=1;y=0;q=a; } else { extend_euclid(b,a%b); int tmp=x; x=y;y=tmp-a/b*y; } }};

2013-05-06 22:52:42 378

原创 高精度运算

const int MAXN = 410; struct bign { int len, s[MAXN]; bign () { memset(s, 0, sizeof(s)); len = 1; } bign (int num) { *this = num; } bign

2013-04-25 18:12:25 433

转载 poj2411 2663 2420 dp+状态压缩(多米诺骨牌问题)

题目描述:用1*2 的矩形通过组合拼成大矩形,求拼成指定的大矩形有几种拼法。首先 我们先求用1*2 的矩形拼成 n*m的矩形有多少种拼法当n*m为奇数时,一定是不会拼出来的,因为想要拼出来就需要整数倍的小矩形数目。为了加速算法,要把m,n中小的那个当做列分两个步骤:1) 先求出相邻两行的转化关系            2) 通过相邻两行的转化关系算出经过n次

2013-04-25 01:22:30 1008

原创 最长公共字串

#include #include #include using namespace std; #define N 1005 char str1[N], str2[N]; int LCS(){ int num[2][N], i, j, k; memset(num, 0, sizeof(num)); for( i = 0; i < strlen(str1);

2013-04-05 00:46:18 722

原创 并查集

const int maxn=333;int n;int parent[maxn];void UFSet(){ for(int i=0;i<=n;i++) parent[i]=-1;}int find(int x){ int s=x; while(parent[s]>0) s=parent[s]; int tmp; while(s!=x) { tmp=pa

2013-04-04 19:01:16 458

原创 树状数组

#define lowbit(x) (x&(-x))int const maxn=3333;int tree[maxn],n;void add(int p,int val){ while(p<=n) { tree[p]+=val; p+=lowbit(p); }}int getsum(int p){ int sum=0; while(p>0) { sum

2013-04-04 18:58:48 392

空空如也

空空如也

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

TA关注的人

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