2011年3月5日

poj 3468

摘要: 经典线段树,大彻大悟了!!!代码:#include<iostream>#include<fstream>using namespace std;struct e{ int left,right; long long add; long long sum;};e tree[400011];long long a[100001];long long build(int s,int t,int num){ long long i,j; tree[num].left=s; tree[num].right=t; tree[num].add=0; if(s!=t) { i=buil 阅读全文

posted @ 2011-03-05 20:51 宇宙吾心 阅读(1641) 评论(0) 推荐(0)

poj 1204

摘要: ac自动机的题。代码:#include <iostream>using namespace std;const int N=1010;int n,m,w;struct trie{ int nxt[27]; int num,fl,id,len;}ac[N*N];int q[N*N];char a[N][N],c[N];int idx;struct nod{ int x,y; char c;}ans[N];void add(char c[],int id,int len){ int p=0; for(int i=0;c[i];i++) { int x=c[i]-'A'; 阅读全文

posted @ 2011-03-05 19:43 宇宙吾心 阅读(420) 评论(2) 推荐(0)

poj 2777

摘要: 线段树题。代码:#include<iostream>#include<fstream>using namespace std;struct e{ int l,r; int color;} tree[800001];int n,m,t;int v[31];void build(int s,int t,int p){ tree[p].l=s; tree[p].r=t; tree[p].color=1; if(t>s) { int mid=(s+t)>>1; build(s,mid,p*2); build(mid+1,t,p*2+1); }}void ins 阅读全文

posted @ 2011-03-05 16:45 宇宙吾心 阅读(171) 评论(0) 推荐(0)

poj 2352

摘要: 线段树题注意思想。代码:#include<iostream>#include<fstream>using namespace std;struct e{ int l,r; int cn;}tree[70000];int level[15001];int n;int x[15001],y[15001];int maxx;void build(int l,int r,int p){ tree[p].l=l; tree[p].r=r; tree[p].cn=0; if(l<r) { int mid=(l+r)>>1; build(l,mid,p*2); bu 阅读全文

posted @ 2011-03-05 10:37 宇宙吾心 阅读(670) 评论(0) 推荐(0)

导航