上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 40 下一页

2014年1月11日

hdu 4080 Stammering Aliens 二分 hash

摘要: POJ 3882 TLE 需后缀数组------------const int SEED = 13331;const int MAX_N = 50000 + 10;char s[MAX_N];struct HASH{ ULL H[MAX_N]; ULL XL[MAX_N]; int len; HASH(){} void build(char *s){ len=strlen(s); H[len]=0; XL[0]=1; for (int i=len-1;i>=0;i--){ H[i]=H[... 阅读全文

posted @ 2014-01-11 21:26 电子幼体 阅读(253) 评论(0) 推荐(0) 编辑

2014年1月10日

POJ 3106 Flip and Turn 模拟 分析

摘要: --------const int maxn=400;const int maxm=200000;int n,m;char a[maxn][maxn];char b[maxn][maxn];int stk[10];int cnt;char s[maxm];char cd[7][3]={"1","CX","V","BY","2","AZ","H"};char sp[7][8]={"1","1H","1H1&q 阅读全文

posted @ 2014-01-10 00:27 电子幼体 阅读(134) 评论(0) 推荐(0) 编辑

UVA 10635 Prince and Princess DP LIS

摘要: --------int n;int a1[111111];int a2[111111];int c[111111];int a[111111];int g[111111];int d[111111];int N,p,q;int main(){ int T; scanf("%d",&T); for (int cas=1;cas<=T;cas++) { scanf("%d%d%d",&N,&p,&q); memset(c,0,sizeof(c)); memset(g,0,sizeof(g)); n=0; ... 阅读全文

posted @ 2014-01-10 00:26 电子幼体 阅读(106) 评论(0) 推荐(0) 编辑

2014年1月9日

URAL 1098 Questions 约瑟夫环

摘要: --------int n;int f[maxn];char s[maxn];int main(){ int n=0; while (gets(s+n)){ n=strlen(s); } s[n]=0; f[0]=0; for (int i=1;i<=n;i++) f[i]=(f[i-1]+1999)%i; if (s[f[n]]=='?') printf("Yes\n"); else if (s[f[n]]==' ') printf("No\n"); else printf("No comments\n& 阅读全文

posted @ 2014-01-09 00:54 电子幼体 阅读(113) 评论(0) 推荐(0) 编辑

2014年1月8日

POJ 2786 Keep the Customer Satisfied 优先队列

摘要: ----------const int maxn=900000;const int maxm=10000;int n;struct Dat{ int v,lim; const bool operatorque;int main(){ while (~scanf("%d",&n)){ for (int i=0;ia[i].lim){ Dat top=que.top(); que.pop(); sum-=top.v; ans++; ... 阅读全文

posted @ 2014-01-08 23:01 电子幼体 阅读(144) 评论(0) 推荐(0) 编辑

UVA 1335 Beijing Guards 二分贪心

摘要: --------const int maxn=110000;const int maxm=10000;int n;int a[maxn];int lb[maxn],rb[maxn];bool C(int x){ lb[0]=a[0]; rb[0]=0; for (int i=1;ia[0]||rb[i]+rb[i-1]>x-a[0]) return false; if (lb[i]+rb[i]>x) return false; if (lb[i]>1; if (C(mid)){ ans=mid; ... 阅读全文

posted @ 2014-01-08 01:40 电子幼体 阅读(174) 评论(0) 推荐(0) 编辑

2014年1月7日

POJ 3169 Layout 差分约束系统

摘要: d_x d_x d_y = mind --> d_x que; int dis[maxn]; void addedge(int u,int v,int c){ edges[edge].w=c,edges[edge].to=v,edges[edge].next=head[u],head[u]=edge++; } void init(int n){ memset(head,-1,sizeof(head)); edge=0; this->n=n; } bool spfa(int s){ in... 阅读全文

posted @ 2014-01-07 22:56 电子幼体 阅读(115) 评论(0) 推荐(0) 编辑

ZOJ 2334 Monkey King 可并堆左偏树

摘要: ----------int n,m;class LeftistTree{private: int tot,v[maxn],l[maxn],r[maxn],d[maxn];public: int merge(int x,int y){ if (!x) return y; if (!y) return x; if (v[x]<v[y]) swap(x,y); r[x]=merge(r[x],y); if (d[l[x]]<d[r[x]]) swap(l[x],r[x]); d[x]=d[r[x]]+1;... 阅读全文

posted @ 2014-01-07 22:10 电子幼体 阅读(144) 评论(0) 推荐(0) 编辑

ZOJ 2112 Dynamic Rankings 线段树套平衡树

摘要: ------------const int N=60010;const int M=10010;class SegmentTree_Treap{private: struct Treap{ int key,fix,cnt,size,ch[2]; }T[N*15]; int tree[Nt) return select(T[x].ch[0],t); return T[x].cnt+T[T[x].ch[0]].size+select(T[x].ch[1],t); }public: void treeins(int l,int r,int i... 阅读全文

posted @ 2014-01-07 00:09 电子幼体 阅读(119) 评论(0) 推荐(0) 编辑

2014年1月6日

POJ 2796 Feel Good 并查集

摘要: 答案为0时要输出一个合理的区间...这是个坑.-----------------------const int maxn=110000;const int maxm=10000;int n;int a[maxn];struct Dat{ int v; int idx;};bool cmp(const Dat& a,const Dat& b){ return a.v>b.v;}Dat b[maxn];int L[maxn],R[maxn],Mis[maxn];int pa[maxn];void makeset(int n){ for (int i=0;i1&& 阅读全文

posted @ 2014-01-06 22:21 电子幼体 阅读(174) 评论(0) 推荐(0) 编辑

上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 40 下一页

导航