2011年5月16日

poj 2001

摘要: trie树代码:#include<iostream>#include<fstream>using namespace std;int n;struct e{ int state[26]; int cnt;};e tree[20004];char c[1004][24];int state;void insert(int s){ int i,j=0; for(i=0;i<strlen(c[s]);i++) { if(tree[j].state[c[s][i]-'a']==0) { tree[j].state[c[s][i]-'a']= 阅读全文

posted @ 2011-05-16 17:30 宇宙吾心 阅读(319) 评论(0) 推荐(0)

poj 2528_2

摘要: 代码:#include<iostream>#include<fstream>using namespace std;struct e{ int l,r; bool isa;};e tree[80001];int n;struct f{ int num,s,l;};f b[20001];int c[10001][2];int cmp(const void *a,const void *b){ f *s=(f*)a; f *t=(f*)b; return s->l-t->l;}void build(int s,int t,int p){ tree[p].l=s; 阅读全文

posted @ 2011-05-16 12:07 宇宙吾心 阅读(248) 评论(0) 推荐(0)

poj 1823

摘要: 代码:#include<iostream>#include<fstream>using namespace std;struct e{ int l,r,cnt,cntl,cntr; int state;};e tree[48001];int n,m;void build(int s,int t,int p){ int i,j,k; tree[p].l=s;tree[p].r=t; tree[p].state=-1; tree[p].cnt=tree[p].cntl=tree[p].cntr=t-s+1; if(s==t) return; else { k=(s+t)&g 阅读全文

posted @ 2011-05-16 11:02 宇宙吾心 阅读(383) 评论(0) 推荐(0)

poj 2777

摘要: 代码:#include<iostream>#include<fstream>using namespace std;int n,m,c;struct e{ int l,r; int state; bool id;};e tree[300001];void build(int s,int t,int p){ int i,j,k; tree[p].l=s; tree[p].r=t; if(s==t) return; k=(s+t)>>1; build(s,k,p*2); build(k+1,t,2*p+1);}void update(int s,int t,in 阅读全文

posted @ 2011-05-16 10:50 宇宙吾心 阅读(556) 评论(0) 推荐(0)

poj 3368_2

摘要: 线段树代码:#include<iostream>#include<fstream>using namespace std;int n,m;struct e{ int l,r,max,maxl,maxr;};e tree[300001];int b[100001];void build(int s,int t,int p){ int i,j,k; tree[p].l=s; tree[p].r=t; if(s==t) { tree[p].max=tree[p].maxl=tree[p].maxr=1; return; } k=(s+t)>>1; build(s, 阅读全文

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

导航