题解 BZOJ 3227 [Sdoi2008]红黑树(tree)

求红黑树红色节点的最大最小值。 参考 百度百科 性质1. 节点是红色或黑色。 性质2. 根节点是黑色。 性质3 每个叶节点(NIL节点,空节点)是黑色的。 性...

三月 12, 2015 · 2 分钟 · 537 字 · Ruotian

题解 BZOJ 2565 最长双回文串

求最长双回文串. 首先Manacher求回文半径p[i]。 然后求每个点最左是可以由哪一个点扩展来的left[i]。 具体就是拿个数组弄一个 i+p[i] 的后...

三月 12, 2015 · 1 分钟 · 196 字 · Ruotian

题解 BZOJ 1970 [Ahoi2005]Code 矿藏编码

写个高精度。 然后扫过去就行了。 抽题器竟然抽了这么水的题233. code: #include<cstdio>#include<cstring>#include<algorithm>using namespace std; int k; struct N{ int a[100]; friend N operator + (const N&a,const N&b){ N c; for(int i=0;i<100;i++) c.a[i]=a.a[i]+b.a[i]; for(int i=0;i<99;i++) c.a[i+1]+=c.a[i]/10,c.a[i]%=10; return c; } N mul2(){ N b; for(int i=0;i<100;i++) b.a[i]=a[i]*2; for(int i=0;i<99;i++) b.a[i+1]+=b.a[i]/10,b.a[i]%=10; return...

三月 12, 2015 · 1 分钟 · 119 字 · Ruotian

题解 BZOJ 1201 [HNOI2005]数三角形

首先看正着的三角形。 每个点向右上方可以扩展的距离叫 mxl[],左上方叫mxr[]。 枚举三角形右下端点。 设右下为j.坐下为i。 需要满足 底边i....

三月 12, 2015 · 1 分钟 · 322 字 · Ruotian

题解 BZOJ 1845 [Cqoi2005] 三角形面积并

题目是求三角形面积并。$n<= 100$ 就像hwd冬令营上讲的。 先$n^2$求交点。 然后在每两个交点之间求梯形中位线总长,然后求和。 ps.听说...

三月 11, 2015 · 1 分钟 · 365 字 · Ruotian

题解 BZOJ 1023 [SHOI2008]cactus仙人掌图

题意是仙人掌图直径。 大概做法就是树的直径dp求法加上基环树的技巧特技。 改了好长好长时间啊。 参考题解: http://z55250825.blog.163.com/blog/static/150230809201412793151890/ 很细致。。 code: #include<cstdio>#include<cstring>#include<algorithm>using namespace std; int n,m; int H[50005],X[20000005],P[20000005],tot=1; int dp[50005]; inline void add(int x,int...

三月 11, 2015 · 1 分钟 · 193 字 · Ruotian

题解 BZOJ 1174 [Balkan2007]Toponyms

给你一个字符集合,你从其中找出一些字符串出来. 希望你找出来的这些字符串的最长公共前缀*字符串的总个数最大化. 这个问题很简单吧..用trie随...

三月 10, 2015 · 1 分钟 · 381 字 · Ruotian

题解 BZOJ 2648 SJY摆棋子

双倍经验2716. KD-Tree模板题。 注意一下"nth_element()" 参考: http://blog.csdn.net/jiangshibiao/article/details/34144829 code: #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int n,m,D,root,x,y; struct N{ int d[2]; int l,r; int min[2];...

一月 7, 2015 · 1 分钟 · 206 字 · Ruotian

题解 BZOJ 1313 取整矩阵

题目 题里的矩阵是这样的: A11 A12 A13… A1n-1 B1 A21 ………. A2n-1 B2 …… An-11 An-12….An-1n-1 Bn-1 C1 C2 C3… Cn-1 0 需要取整。每个元素大概有两种选择,一种是floor另一种是ceil。 这两种之间差...

一月 7, 2015 · 1 分钟 · 373 字 · Ruotian