对于每个点维护两棵线段树$T1[x],T2[x]$: $T1[x]$维护$x$子树内,深度在$[l,r]$内的点数,同种颜色有多个的话,保留深度最小的那个。 $T2[x]$维护$x$子树内每种颜色的最小深度。 从底向上合并线段树,先合并$T1$,然后合并$T2$的时候,发现有重复点,那么在$T1$里 ...
分类:
其他好文 时间:
2016-05-29 06:23:14
阅读次数:
293
Vasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was stolen while he was on duty. He doesn't want to be fi ...
分类:
其他好文 时间:
2016-05-23 06:44:00
阅读次数:
251
自己画一个3*3的方格图, 然后标上 a, b, c, d 然后发现左上角标上x, 中间标上y,然后剩余3个空格可以表示出来。
故可以O(n)的来做
扫一遍,过程中用ans[][][][]来表示那个状态的个数。
最后得到不同的个数
然后n*ans.size()就好了,(n 表示中间的数字的可能情况总数为n), 然后注意可能溢出就好了……
Solution 2 建一个结构体 q, 然后四个成员 ru(rights up), lu(lest up), ld(lest down) and rd(right dow...
分类:
其他好文 时间:
2016-05-18 18:27:28
阅读次数:
223
数学 A - Infinite Sequence 等差数列,公差是0的时候特判 数学 B - Restoring Painting 题意:3*3的矩阵,已经填了a,b,c,d四个数字,问填完数后四个2*2的子矩阵的和相等的方案数,所有数字范围在[1, n]. 分析:蛮有意思的题目,很明显中心的数字是 ...
分类:
其他好文 时间:
2016-05-18 17:33:32
阅读次数:
249
Problems #Name A Infinite Sequence standard input/output 1 s, 256 MB x3509 B Restoring Painting standard input/output 1 s, 256 MB x2519 C Money Transf ...
分类:
编程语言 时间:
2016-05-18 01:36:33
阅读次数:
328
问题 不管你用DBFirst,ModelFirst或是CodeFirst的方式,你想用实体键获取一个单独的实体.在本例中,我们用CodeFirst的方式. 解决方案 假设你有一个模型表示一个Painting(绘画)类型的实体,如Figure 13-2所示: Figure 13-2. The Pain ...
分类:
其他好文 时间:
2016-05-15 00:30:10
阅读次数:
206
关于Nightwatch?Nightwatch.js是一个测试web app和web 站点的自动化测试框架, 使用Node.js编写, 基于Selenium WebDriver API.它是一个完整的浏览器端真实用户场景测试解决方案, 致力于简化继续集成和编写自动化测试。
Nightwatch got its name from the famous painting The Night Wat...
分类:
Web程序 时间:
2016-05-10 07:11:24
阅读次数:
293
There are a row of n houses, each house can be painted with one of the three colors: red, blue or green. The cost of painting each house with a certai ...
分类:
其他好文 时间:
2016-04-30 13:00:19
阅读次数:
140
There are a row of n houses, each house can be painted with one of the k colors. The cost of painting each house with a certain color is different. Yo ...
分类:
其他好文 时间:
2016-04-30 12:44:50
阅读次数:
215