2333: [SCOI2011]棘手的操作

Description

有N个节点,标号从1到N,这N个节点一开始相互不连通。第i个节点的初始权值为a[i],接下来有如下一些操作:

U x y: 加一条边,连接第x个节点和第y个节点

A1 x v: 将第x个节点的权值增加v

A2 x v: 将第x个节点所在的连通块的所有节点的权值都增加v

A3 v: 将所有节点的权值都增加v

F1 x: 输出第x个节点当前的权值

F2 x: 输出第x个节点所在的连通块中,权值最大的节点的权值

F3: 输出所有节点中,权值最大的节点的权值

Input

输入的第一行是一个整数N,代表节点个数。

接下来一行输入N个整数,a[1], a[2], …, a[N],代表N个节点的初始权值。

再下一行输入一个整数Q,代表接下来的操作数。

最后输入Q行,每行的格式如题目描述所示。

Output

对于操作F1, F2, F3,输出对应的结果,每个结果占一行。

Sample Input

3

0 0 0

8

A1 3 -20

A1 2 20

U 1 3

A2 1 10

F1 3

F2 3

A3 -10

F3

Sample Output

-10

10

10

HINT

对于30%的数据,保证 N<=100,Q<=10000

对于80%的数据,保证 N<=100000,Q<=100000

对于100%的数据,保证 N<=300000,Q<=300000

对于所有的数据,保证输入合法,并且 -1000<=v, a[1], a[2], …, a[N]<=1000

【分析】

  这题不知道算不算有想法?

  还是看了题解,其实也不是很难想,可能是我做的题太少了。 【不会可并堆ORZ】

  然后这一题可以离线,因为add的是联通块,而且一旦union也就不会分开了,所以就会希望可以把点重新编号,联通块的编号在一个区间里(因为可以离线)。

  所以,先预处理,建一棵合并过程的树,用并查集维护,即连接两个联通块时新建一个点,左右孩子连两个连通块的fa,用dfs序,进行查询,修改。【orz奥爷爷

  1. #include<cstdio>
  2. #include<cstdlib>
  3. #include<cstring>
  4. #include<iostream>
  5. #include<algorithm>
  6. #include<cmath>
  7. #include<vector>
  8. using namespace std;
  9. #define Maxn 300010
  10.  
  11. int son[*Maxn][];
  12. int a[Maxn],fa[Maxn*]/*,f[Maxn*2]*/,tot;
  13. char s[];
  14.  
  15. int mymax(int x,int y) {return x>y?x:y;}
  16.  
  17. struct hp
  18. {
  19. int op,x,y,id;
  20. }q[Maxn];int ql;
  21.  
  22. int ffa(int x)
  23. {
  24. if(x!=fa[x]) fa[x]=ffa(fa[x]);
  25. return fa[x];
  26. }
  27.  
  28. int n;
  29. void init()
  30. {
  31. scanf("%d",&n);
  32. for(int i=;i<=n;i++) scanf("%d",&a[i]);
  33. for(int i=;i<=n;i++) fa[i]=i;tot=n;
  34. int m;
  35. scanf("%d",&m);
  36. ql=;
  37. memset(son,,sizeof(son));
  38. for(int i=;i<=m;i++)
  39. {
  40. scanf("%s",s);
  41. int x,y;
  42. if(s[]=='U')
  43. {
  44. scanf("%d%d",&x,&y);
  45. if(ffa(x)==ffa(y)) continue;
  46. tot++;
  47. son[tot][]=ffa(x);son[tot][]=ffa(y);
  48. fa[tot]=tot;
  49. fa[ffa(x)]=tot;fa[ffa(y)]=tot;
  50. }
  51. else if(s[]=='A'&&s[]=='')
  52. {
  53. scanf("%d%d",&x,&y);
  54. q[++ql].op=;q[ql].x=x;q[ql].y=y;
  55. }
  56. else if(s[]=='A'&&s[]=='')
  57. {
  58. scanf("%d%d",&x,&y);
  59. q[++ql].op=;q[ql].x=x;q[ql].y=y;q[ql].id=ffa(x);
  60. }
  61. else if(s[]=='A')
  62. {
  63. scanf("%d",&x);
  64. q[++ql].op=;q[ql].x=x;
  65.  
  66. }
  67. else if(s[]=='F'&&s[]=='')
  68. {
  69. scanf("%d",&x);
  70. q[++ql].op=;q[ql].x=x;
  71. }
  72. else if(s[]=='F'&&s[]=='')
  73. {
  74. scanf("%d",&x);
  75. q[++ql].op=;q[ql].x=x;q[ql].id=ffa(x);
  76. }
  77. else
  78. {
  79. q[++ql].op=;
  80. }
  81. }
  82. }
  83.  
  84. int cnt,dfn[Maxn],lf[*Maxn],rt[*Maxn];
  85. void dfs(int x)
  86. {
  87. if(x<=n)
  88. {
  89. dfn[x]=++cnt;
  90. lf[x]=rt[x]=dfn[x];
  91. return;
  92. }
  93. dfs(son[x][]);lf[x]=lf[son[x][]];
  94. dfs(son[x][]);rt[x]=rt[son[x][]];
  95. }
  96.  
  97. struct node
  98. {
  99. int l,r,lc,rc,mx;
  100. int lazy;
  101. }t[Maxn*];int len;
  102.  
  103. void upd(int x)
  104. {
  105. if(t[x].lazy==) return;
  106. t[x].mx+=t[x].lazy;
  107. if(t[x].l!=t[x].r)
  108. {
  109. int lc=t[x].lc,rc=t[x].rc;
  110. t[lc].lazy+=t[x].lazy;
  111. t[rc].lazy+=t[x].lazy;
  112. }
  113. t[x].lazy=;
  114. }
  115.  
  116. int build(int l,int r)
  117. {
  118. int x=++len;
  119. t[x].l=l;t[x].r=r;t[x].mx=;
  120. t[x].lazy=;
  121. if(l!=r)
  122. {
  123. int mid=(l+r)>>;
  124. t[x].lc=build(l,mid);
  125. t[x].rc=build(mid+,r);
  126. }
  127. else t[x].lc=t[x].rc=;
  128. return x;
  129. }
  130.  
  131. void add(int x,int l,int r,int y)
  132. {
  133. if(y==) return;
  134. if(t[x].l==l&&t[x].r==r)
  135. {
  136. t[x].lazy+=y;
  137. return;
  138. }
  139. upd(x);
  140. int mid=(t[x].l+t[x].r)>>;
  141. if(r<=mid) add(t[x].lc,l,r,y);
  142. else if(l>mid) add(t[x].rc,l,r,y);
  143. else
  144. {
  145. add(t[x].lc,l,mid,y);
  146. add(t[x].rc,mid+,r,y);
  147. }
  148. int lc=t[x].lc,rc=t[x].rc;
  149. upd(lc);upd(rc);
  150. t[x].mx=mymax(t[lc].mx,t[rc].mx);
  151. }
  152.  
  153. int query(int x,int l,int r)
  154. {
  155. upd(x);
  156. if(t[x].l==l&&t[x].r==r) return t[x].mx;
  157. int mid=(t[x].l+t[x].r)>>;
  158. if(r<=mid) return query(t[x].lc,l,r);
  159. else if(l>mid) return query(t[x].rc,l,r);
  160. else return mymax(query(t[x].lc,l,mid),query(t[x].rc,mid+,r));
  161. }
  162.  
  163. int main()
  164. {
  165. init();
  166. len=;
  167. build(,tot);
  168. cnt=;int ad=;
  169. for(int i=;i<=tot;i++) if(ffa(i)==i)
  170. {
  171. dfs(i);
  172. }
  173. for(int i=;i<=n;i++) add(,dfn[i],dfn[i],a[i]);
  174. for(int i=;i<=ql;i++)
  175. {
  176. if(q[i].op==)
  177. {
  178. // printf("add %d %d %d\n",dfn[q[i].x],dfn[q[i].x],q[i].y);
  179. add(,dfn[q[i].x],dfn[q[i].x],q[i].y);
  180. }
  181. else if(q[i].op==)
  182. {
  183. // printf("add %d %d %d\n",lf[q[i].id],rt[q[i].id],q[i].y);
  184. add(,lf[q[i].id],rt[q[i].id],q[i].y);
  185. }
  186. else if(q[i].op==)
  187. {
  188. ad+=q[i].x;
  189. }
  190. else if(q[i].op==)
  191. {
  192. // printf("ask %d %d\n",dfn[q[i].x],dfn[q[i].x]);
  193. int now=query(,dfn[q[i].x],dfn[q[i].x]);
  194. printf("%d\n",now+ad);
  195. }
  196. else if(q[i].op==)
  197. {
  198. // printf("ask %d %d\n",lf[q[i].id],rt[q[i].id]);
  199. int now=query(,lf[q[i].id],rt[q[i].id]);
  200. printf("%d\n",now+ad);
  201. }
  202. else if(q[i].op==)
  203. {
  204. int now=query(,,cnt);
  205. printf("%d\n",now+ad);
  206. }
  207. }
  208. return ;
  209. }

2016-11-10 09:49:34


学了可并堆我回来更新啦哈哈哈哈【傻。。

【感觉这个题号在嘲笑我><】

左偏树,还要带lazy标记,还要加一个set,呵呵呵,因为看不懂别人的,所以自己YYYYY,所以就乱搞了一整天+很多呆滞的moment。。

细节真心超多,

我搞了个rt(用并查集维护),还有一个fa(左偏树中直属父亲)。

fa,从下往上找,然后从上往下pushdown那里好像有点慢,不过我看黄学长这里也是这样的。【表示左偏树做法比离线慢呐~~

A1操作先删点,再加点,细节很多!!!【因为我乱搞呵呵呵呵
= =或许应该看这个题解:http://blog.csdn.net/charlie_pyc/article/details/20830305

  1. #include<cstdio>
  2. #include<cstdlib>
  3. #include<cstring>
  4. #include<iostream>
  5. #include<algorithm>
  6. #include<set>
  7. using namespace std;
  8. #define Maxn 300010
  9. #define INF 0x7fffffff
  10.  
  11. int mymax(int x,int y) {return x>y?x:y;}
  12.  
  13. int a[Maxn],all=;
  14. int n,q,cnt;
  15. char s[];
  16.  
  17. multiset<int > ss;
  18.  
  19. struct node
  20. {
  21. int x,lc,rc,dis,fa,rt;
  22. int lazy;
  23. }t[Maxn];
  24.  
  25. void upd(int x)
  26. {
  27. t[x].lc=t[x].rc=;
  28. t[x].dis=;t[x].lazy=;
  29. t[x].fa=;
  30. }
  31.  
  32. void era(int x)
  33. {
  34. multiset<int>:: iterator it;
  35. it=ss.find(x);
  36. ss.erase(it);
  37. }
  38.  
  39. int v[Maxn];
  40. struct Ltree
  41. {
  42. int rtt(int x)
  43. {
  44. if(t[x].rt!=x) t[x].rt=rtt(t[x].rt);
  45. return t[x].rt;
  46. }
  47. void pushdown(int x)
  48. {
  49. if(t[x].lc) t[t[x].lc].lazy+=t[x].lazy;
  50. if(t[x].rc) t[t[x].rc].lazy+=t[x].lazy;
  51. t[x].x+=t[x].lazy;
  52. t[x].lazy=;
  53. }
  54. int merge(int x,int y)
  55. {
  56. if(x==||y==) return x+y;
  57. pushdown(x);pushdown(y);
  58. if(t[x].x<t[y].x) swap(x,y);
  59. t[x].rc=merge(t[x].rc,y);
  60. if(t[x].rc) t[t[x].rc].fa=x;
  61. if(t[t[x].lc].dis<t[t[x].rc].dis) swap(t[x].lc,t[x].rc);
  62. t[x].dis=t[t[x].rc].dis+;
  63. return x;
  64. }
  65. void sol(int x)
  66. {
  67. v[]=;
  68. while(x) v[++v[]]=x,x=t[x].fa;
  69. while(v[]) pushdown(v[v[]--]);
  70. }
  71. int add(int x,int y)
  72. {
  73. int xx=rtt(x);
  74. pushdown(xx);era(t[xx].x);sol(x);
  75. int nw=merge(t[x].lc,t[x].rc);
  76. if(t[x].fa)
  77. {
  78. if(t[t[x].fa].lc==x) t[t[x].fa].lc=nw;
  79. else t[t[x].fa].rc=nw;
  80. }
  81. if(nw)
  82. {
  83. t[nw].fa=t[x].fa;
  84. }
  85. t[x].x+=y;upd(x);
  86. if(x!=xx) nw=merge(x,xx);
  87. else nw=merge(x,nw);
  88.  
  89. t[x].rt=t[xx].rt=t[nw].rt=nw;
  90. pushdown(nw);
  91. ss.insert(t[nw].x);
  92. }
  93. }heap;
  94.  
  95. int main()
  96. {
  97. scanf("%d",&n);
  98. t[].dis=-;
  99. for(int i=;i<=n;i++) scanf("%d",&a[i]);
  100. for(int i=;i<=n;i++) upd(i),t[i].x=a[i],t[i].fa=,t[i].rt=i;
  101. ss.clear();
  102. for(int i=;i<=n;i++) ss.insert(a[i]);
  103.  
  104. scanf("%d",&q);
  105. for(int i=;i<=q;i++)
  106. {
  107. scanf("%s",s);
  108. int x,y;
  109. if(s[]=='U')
  110. {
  111. scanf("%d%d",&x,&y);
  112. int xx=heap.rtt(x),yy=heap.rtt(y);
  113. if(xx==yy) continue;
  114. heap.pushdown(xx);era(t[xx].x);
  115. heap.pushdown(yy);era(t[yy].x);
  116. int nw=heap.merge(xx,yy);
  117. t[xx].rt=t[yy].rt=nw;
  118. heap.pushdown(nw);ss.insert(t[nw].x);
  119. }
  120. else if(s[]=='A')
  121. {
  122. if(s[]=='')
  123. {
  124. scanf("%d%d",&x,&y);
  125. heap.add(x,y);
  126. }
  127. else if(s[]=='')
  128. {
  129. scanf("%d%d",&x,&y);
  130. int xx=heap.rtt(x);
  131. heap.pushdown(xx);
  132. era(t[xx].x);
  133. t[xx].lazy+=y;
  134. heap.pushdown(xx);
  135. ss.insert(t[xx].x);
  136. }
  137. else
  138. {
  139. scanf("%d",&x);
  140. all+=x;
  141. }
  142. }
  143. else
  144. {
  145. if(s[]=='')
  146. {
  147. scanf("%d",&x);
  148. heap.sol(x);
  149. heap.pushdown(x);
  150. printf("%d\n",t[x].x+all);
  151. }
  152. else if(s[]=='')
  153. {
  154. scanf("%d",&x);
  155. int xx=heap.rtt(x);
  156. heap.pushdown(xx);
  157. printf("%d\n",t[xx].x+all);
  158. }
  159. else
  160. {
  161. printf("%d\n",*(--ss.end())+all);
  162. }
  163. }
  164. }
  165. return ;
  166. }

2017-01-20 17:05:47


在后面再写一题:(因为没A就插在AC的题目后面吧)

HDU5454

【题意】

n*n的矩阵,每次对连续的一段对角线全部加1,每次询问一个子矩阵的和(n<=200000)

【分析】

跟那道矩阵旋转的线段树维护有点像。要对矩阵的对角线以及旋转有很深的理解才行啊。。。

对于左斜线来说,加的值都是一样的,右斜线也是。所以可以分开维护。

一个矩形就可以分成一个平行四边形和两个三角形咯,平行四边形那里对角线长度相等,可以求和,三角形的话,对角线长度是递增的,所以可以维护类似a[i]*i的前缀和。。、

超难打ORZ .....

放个还没有AC的代码:

  1. #include<cstdio>
  2. #include<cstdlib>
  3. #include<cstring>
  4. #include<iostream>
  5. #include<algorithm>
  6. #include<cmath>
  7. using namespace std;
  8. #define INF 0xfffffff
  9. #define Maxn 200010
  10.  
  11. struct node
  12. {
  13. int l,r,lc,rc,f[],f1[],f2[];
  14. int lazy[];
  15. }t[*Maxn];int len;
  16.  
  17. int n,m;
  18. int myabs(int x) {return x>?x:-x;}
  19. int mymin(int x,int y) {return x<y?x:y;}
  20. int mymax(int x,int y) {return x>y?x:y;}
  21.  
  22. int build(int l,int r)
  23. {
  24. int x=++len;
  25. t[x].l=l;t[x].r=r;
  26. t[x].f[]=t[x].f[]=t[x].f1[]=t[x].f1[]=t[x].f2[]=t[x].f2[]=;
  27. t[x].lazy[]=t[x].lazy[]=;
  28. if(l!=r)
  29. {
  30. int mid=(l+r)>>;
  31. t[x].lc=build(l,mid);
  32. t[x].rc=build(mid+,r);
  33. }
  34. else t[x].lc=t[x].rc=;
  35. return x;
  36. }
  37.  
  38. int gsum(int l,int r)
  39. {
  40. return (l+r)*(r-l+)/;
  41. }
  42.  
  43. void upd(int x,int p)
  44. {
  45. if(t[x].lazy[p]==) return;
  46. int lc=t[x].lc,rc=t[x].rc;
  47. t[x].f[p]+=t[x].lazy[p]*(t[x].r-t[x].l+);
  48. t[x].f1[p]+=t[x].lazy[p]*gsum(t[x].l,t[x].r);
  49. t[x].f2[p]+=t[x].lazy[p]*gsum(*n-t[x].r,*n-t[x].l);
  50. t[lc].lazy[p]+=t[x].lazy[p];t[rc].lazy[p]+=t[x].lazy[p];
  51. t[x].lazy[p]=;
  52. return;
  53. }
  54.  
  55. void change(int x,int l,int r,int p)
  56. {
  57. if(t[x].l==l&&t[x].r==r)
  58. {
  59. t[x].lazy[p]++;
  60. return;
  61. }
  62. upd(x,p);
  63. int mid=(t[x].l+t[x].r)>>;
  64. if(r<=mid) change(t[x].lc,l,r,p);
  65. else if(l>mid) change(t[x].rc,l,r,p);
  66. else
  67. {
  68. change(t[x].lc,l,mid,p);
  69. change(t[x].rc,mid+,r,p);
  70. }
  71. int lc=t[x].lc,rc=t[x].rc;
  72. upd(lc,p);
  73. upd(rc,p);
  74. t[x].f[p]=t[lc].f[p]+t[rc].f[p];
  75. t[x].f1[p]=t[lc].f1[p]+t[rc].f1[p];
  76. t[x].f2[p]=t[lc].f2[p]+t[rc].f2[p];
  77. }
  78.  
  79. int query(int x,int l,int r,int p,int op)
  80. {
  81. int tt;
  82. if(l>r) tt=l,l=r,r=tt;
  83. if(r>*n-) r=*n-;
  84. if(l<) l=;
  85. upd(x,p);
  86. if(t[x].l==l&&t[x].r==r)
  87. {
  88. if(op==) return t[x].f1[p];
  89. else if(op==) return t[x].f2[p];
  90. else return t[x].f[p];
  91. }
  92. int mid=(t[x].l+t[x].r)>>;
  93. if(r<=mid) return query(t[x].lc,l,r,p,op);
  94. else if(l>mid) return query(t[x].rc,l,r,p,op);
  95. else return query(t[x].lc,l,mid,p,op)+query(t[x].rc,mid+,r,p,op);
  96. }
  97.  
  98. int main()
  99. {
  100. int T,kase=;
  101. scanf("%d",&T);
  102. while(T--)
  103. {
  104. scanf("%d%d",&n,&m);
  105. len=;
  106. build(,*n-);
  107. printf("Case #%d:\n",++kase);
  108. for(int i=;i<=m;i++)
  109. {
  110. int opt;
  111. scanf("%d",&opt);
  112. int l,r;
  113. if(opt==)
  114. {
  115. scanf("%d%d",&l,&r);
  116. l--;r--;
  117. printf("%d %d %d\n",l,r,);
  118. change(,l,r,);
  119. }
  120. else if(opt==)
  121. {
  122. scanf("%d%d",&l,&r);
  123. l+=n;r+=n;
  124. printf("%d %d %d\n",l,r,);
  125. change(,l,r,);
  126. }
  127. else
  128. {
  129. int a,b;
  130. scanf("%d%d%d%d",&l,&a,&r,&b);
  131. int ans=;
  132. ans+=(query(,a+r-,l+b-,,)+query(,l-r+n,a-b+n,,))*mymin(a-l+,b-r+);
  133. //zhu
  134. int kk=mymin(a+r-,l+b-);
  135. ans+=query(,l+r-,kk,,)-query(,l+r-,kk,,)*(l+r-);//左上
  136. kk=mymax(a+r,l+b);
  137. ans+=query(,kk,a+b-,,)-query(,kk,a+b-,,)*(*n-(a+b-)-);//右下
  138. //fu
  139. kk=mymin(a-b+n-,l-r+n-);
  140. ans+=query(,l-b+n,kk,,)-query(,l-b+n,kk,,)*(l-b+n-);//右上
  141.  
  142. kk=mymax(a-b+n+,l-r+n+);
  143. ans+=query(,kk,a-r+n,,)-query(,kk,a-r+n,,)*(*n-(a-r+n)-);//左下
  144. printf("%d\n",ans);
  145. }
  146. }
  147. }
  148. return ;
  149. }

有空的话,再填坑吧。。

2016-11-10 09:54:11

【BZOJ 2333 】[SCOI2011]棘手的操作(离线+线段树|可并堆-左偏树)的更多相关文章

  1. 2333: [SCOI2011]棘手的操作[离线线段树]

    2333: [SCOI2011]棘手的操作 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 2325  Solved: 909[Submit][Stat ...

  2. BZOJ 2333 SCOI2011 棘手的操作 并查集+可并堆

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2333 ..题意概述就不写了,各位老爷如果是看着玩的可以去搜一下,如果是做题找来的也知道题干 ...

  3. bzoj 2333 [SCOI2011]棘手的操作 —— 可并堆

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2333 稍微复杂,参考了博客:http://hzwer.com/5780.html 用 set ...

  4. BZOJ 2333: [SCOI2011]棘手的操作 可并堆 左偏树 set

    https://www.lydsy.com/JudgeOnline/problem.php?id=2333 需要两个结构分别维护每个连通块的最大值和所有连通块最大值中的最大值,可以用两个可并堆实现,也 ...

  5. BZOJ 2333: [SCOI2011]棘手的操作

    题目描述 真的是个很棘手的操作.. 注意每删除一个点,就需要clear一次. #include<complex> #include<cstdio> using namespac ...

  6. BZOJ 2333 [SCOI2011]棘手的操作 (可并堆)

    码农题.. 很显然除了两个全局操作都能用可并堆完成 全局最大值用个multiset记录,每次合并时搞一搞就行了 注意使用multiset删除元素时 如果直接delete一个值,会把和这个值相同的所有元 ...

  7. 2333: [SCOI2011]棘手的操作[写不出来]

    2333: [SCOI2011]棘手的操作 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1979  Solved: 772[Submit][Stat ...

  8. 2333: [SCOI2011]棘手的操作[我不玩了]

    2333: [SCOI2011]棘手的操作 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1979  Solved: 772[Submit][Stat ...

  9. 【BZOJ】2333: [SCOI2011]棘手的操作

    http://www.lydsy.com/JudgeOnline/problem.php?id=2333 题意: 有N个节点,标号从1到N,这N个节点一开始相互不连通.第i个节点的初始权值为a[i], ...

随机推荐

  1. [学习笔记]最小割之最小点权覆盖&&最大点权独立集

    最小点权覆盖 给出一个二分图,每个点有一个非负点权 要求选出一些点构成一个覆盖,问点权最小是多少 建模: S到左部点,容量为点权 右部点到T,容量为点权 左部点到右部点的边,容量inf 求最小割即可. ...

  2. 洛谷P2568 GCD (欧拉函数/莫比乌斯反演)

    P2568 GCD 题目描述 给定整数N,求1<=x,y<=N且Gcd(x,y)为素数的数对(x,y)有多少对. 输入输出格式 输入格式: 一个整数N 输出格式: 答案 输入输出样例 输入 ...

  3. vue2学习篇一 $mount()手动挂载

    $mount()手动挂载 //当Vue实例没有el属性时,则该实例尚没有挂载到某个dom中: //假如需要延迟挂载,可以在之后手动调用vm.$mount()方法来挂载.例如: new Vue({ // ...

  4. Jquery 获取checkbox的checked问题以及解决方案

    转载自:http://www.cnblogs.com/-run/archive/2011/11/16/2251250.html 这个郁闷了,今天写这个功能的时候发现了问题,上网找了好多资料对照,更加纠 ...

  5. 栈与递归的实现(Hanoi塔问题等等)

    函数中有直接或间接地调用自身函数的语句,这样的函数称为递归函数.递归函数用 得好,可简化编程工作.但函数自己调用自己,有可能造成死循环.为了避免死循环,要 做到两点: (1) 降阶.递归函数虽然调用自 ...

  6. [05]Git查看、删除、重命名远程分支和tag

    Git查看.删除.重命名远程分支和tag 2015-06-15:加入姊妹篇: 2013-11-06:加入重命名远程分支的内容: 2013-01-09:加入删除远程tag的内容. 姊妹篇:使用Git.G ...

  7. js实现日历

    有这样一个普通的日历需求 第一反应就是找插件,结果找到了,但是改起来非常麻烦,然后查下实现的原理,发现原来很简单,于是自己实现了一个. 首先分析一下这个组件,每页显示的是 当前月的所有日期及所占据的行 ...

  8. hive向表格中插入数据并分析语句

    1,---导入mds_imei_month_info ; //最大的动态分区表 set hive.support.concurrency=false; //是否支持并发 ; //each mapper ...

  9. [BZOJ3261&BZOJ3166]可持久化trie树及其应用

    可持久化trie树 可持久化trie树现在想来是比较好理解的了,但却看了一个下午... 相当于对于每个状态建立一条链(或者说一棵trie),求解的时候只要让两个点按照相同的步子走然后看sum的大小关系 ...

  10. 【STSRM12】整除

    [题意]给定长度为n的序列A,求最长的区间满足区间内存在数字能整除区间所有数字,同时求所有方案.n<=5*10^5,Ai<2^31. [算法]数论??? [题解]首先一个区间的基准数一定是 ...