随笔分类 -  线段树

摘要:小朋友排队 问题描述 n 个小朋友站成一排。现在要把他们按身高从低到高的顺序排列,但是每次只能交换位置相邻的两个小朋友。 每个小朋友都有一个不高兴的程度。开始的时候,所有小朋友的不高兴程度都是0。 如果某个小朋友第一次被要求交换,则他的不高兴程度增加1,如果第二次要求他交换,则他的不高兴程度增加2( 阅读全文
posted @ 2019-02-05 22:02 *starry* 阅读(355) 评论(0) 推荐(0)
摘要:Ultra-QuickSort OpenJ_Bailian - 2299 In this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n dist 阅读全文
posted @ 2018-09-26 20:42 *starry* 阅读(184) 评论(0) 推荐(0)
摘要:Lucky Queries CodeForces - 145E Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record con 阅读全文
posted @ 2018-09-06 20:36 *starry* 阅读(203) 评论(0) 推荐(0)
摘要:Traffic Jams in the Land CodeForces - 498D Some country consists of (n + 1) cities, located along a straight highway. Let's number the cities with con 阅读全文
posted @ 2018-09-06 11:52 *starry* 阅读(254) 评论(0) 推荐(0)
摘要:坤坤的最佳咖啡 坤坤的最佳咖啡 坤坤的最佳咖啡 Description 为了在课堂上保持清醒和专注,坤坤需要一些咖啡! 作为咖啡爱好者的它想知道煮一杯完美咖啡的最佳温度。事实上,它花了一段时间阅读了一些书籍。某些本书表明,咖啡应该在[Li,Ri]度之间酿造,以达到最佳口味。 坤坤认为,它要煮出完美咖 阅读全文
posted @ 2018-08-29 09:41 *starry* 阅读(161) 评论(0) 推荐(0)
摘要:线段树+dfs序 给定一棵n个节点的树,m次查询,每次查询需要求出某个节点深度为h的所有子节点。 作为预处理,首先将树的所有节点按深度保存起来,每个深度的所有节点用一个线性结构保存,每个深度的节点相对顺序要和前序遍历一致。 然后从树的根节点进行dfs,对于每个节点记录两个信息,一个是dfs进入该节点 阅读全文
posted @ 2018-08-09 18:44 *starry* 阅读(299) 评论(0) 推荐(0)
摘要:Atlantis There are several ancient Greek texts that contain descriptions of the fabled island Atlantis. Some of these texts even include maps of parts 阅读全文
posted @ 2018-08-08 20:45 *starry* 阅读(271) 评论(0) 推荐(0)
摘要:During the War of Resistance Against Japan, tunnel warfare was carried out extensively in the vast areas of north China Plain. Generally speaking, vil 阅读全文
posted @ 2018-08-07 21:27 *starry* 阅读(151) 评论(0) 推荐(0)
摘要:The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral posters at all pl 阅读全文
posted @ 2018-08-07 16:54 *starry* 阅读(499) 评论(0) 推荐(0)
摘要:链接: 树状数组 例题:HDU 1556 N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的“小飞鸽"牌电动车从气球a开始到气球b依次给每个气球涂一次颜色。但是N次以后lele已经忘记了第I个气球已经涂过几次颜色了,你能帮他算出每个 阅读全文
posted @ 2018-07-09 00:24 *starry* 阅读(134) 评论(0) 推荐(0)
摘要:vj题目链接: https://vjudge.net/contest/235444#problem/F 题意: 有 n 个待建的喷泉,每个的建造代价为pi coins或者pi diamonds(coins 和 diamonds 不可互相兑换),每个喷泉的魅力为bi。问在原有c coins和d dia 阅读全文
posted @ 2018-07-08 16:01 *starry* 阅读(176) 评论(0) 推荐(1)