2012年7月12日

POJ 2503 Babelfish

摘要: 字典树,WA;----------------------------------------------------# include <stdio.h># include <string.h># define LEN 12char buf[2 * LEN], str[LEN];struct word{ char a[LEN];} ;struct tree{ tree *node[26]; char bj; word *pw; tree() { for (int i = 0; i < 26; ++i) node[i] = NU... 阅读全文

posted @ 2012-07-12 17:35 getgoing 阅读(233) 评论(0) 推荐(0)

POJ 3468 A Simple Problem with Integers

摘要: 线段树,维护区间的和,支持区间范围修改,注意由于增加的标记传递时是累加起来,结果会超出 int ,要用 long long;--------------------------------------------------------------DescriptionYou have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given int 阅读全文

posted @ 2012-07-12 15:32 getgoing 阅读(182) 评论(0) 推荐(0)

COJ 0712 Can you answer these queries II

摘要: ------------------------------------------------------------------------------------线段树的区间操作:修改区间内的值,反转区间内的值,区间查询;------------------------------------------------------------------------------------Description维护一个只有0和1的整数序列,支持以下操作:1 x y v : 将区间[x,y]之间的所有整数都变为v(v为0或1);2 x y : 将区间[x,y]之间所有的1变为0,所有的0变为 阅读全文

posted @ 2012-07-12 13:56 getgoing 阅读(272) 评论(0) 推荐(0)

HDOJ 1394 Minimum Inversion Number

摘要: 线段树,维护的是区间内整数的个数,每次插入 x 时,查询在 x 的前面比小的数的个数,并计算出比 x 大的数的个数 cnt[x] ,最后将 cnt 累加,即为逆序数;将队首的数放到队尾后逆序数改变:n-1-a[i], a[i] 为原始序列中第 i 个数的值;----------------------------------------------------------------------2012/7/15之前的代码中,cnt[i] 是记录比第 i 个数大的的在它前面出现的数的个数,第二次写发现不需要。# include <cstdio># include <cstri 阅读全文

posted @ 2012-07-12 10:38 getgoing 阅读(227) 评论(0) 推荐(0)

POJ 2352 Stars

摘要: 因为输入是按y坐标升序的,对每个点统计在它左边的个数就是它的level(线段树);DescriptionAstronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars that are not higher and not to the right of the given star. Astronomers 阅读全文

posted @ 2012-07-12 09:48 getgoing 阅读(961) 评论(0) 推荐(0)

导航