摘要: http://dongxicheng.org/structure/segment-tree/线段树,也叫区间树,是一个完全二叉树,它在各个节点保存一条线段(即“子数组”),因而常用于解决数列维护问题,它基本能保证每个操作的复杂度为O(lgN)。线段树的基本操作主要包括构造线段树,区间查询和区间修改。struct node{ int ld,rd;//左右边界 node *lc,*rc;//左右孩子 int key;//信息域 如RMQ问题中,信息域中存储的是区间最大值};建树//空树的建立,内含key值的初始化; //一般在主函数中首先调用 Node* root= buildt... 阅读全文
posted @ 2012-07-25 17:25 _雨 阅读(232) 评论(2) 推荐(0) 编辑
摘要: 百练2981 http://poj.grids.cn/practice/2981/View Code 1 #include<stdio.h> 2 #include<string.h> 3 int num[301]; 4 int main() 5 { 6 int i,j,f = 0,f1; 7 char c1[201],c2[201]; 8 gets(c1); 9 gets(c2);10 i = strlen(c1)-1;11 j = strlen(c2)-1;12 int g = 0;13 while(i>=0&&j>=0)14... 阅读全文
posted @ 2012-07-25 16:32 _雨 阅读(212) 评论(0) 推荐(0) 编辑
摘要: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1135好繁琐的一道模拟题 细节很重要 编译错误一次 把字符串结尾写错WA一次 多了getchar()WA一次 多了以空格PE一次 最后AC...3个多小时用了一下map map还是很方便的View Code 1 #include <iostream> 2 #include<map> 3 #include<stdio.h> 4 #include&l 阅读全文
posted @ 2012-07-25 10:44 _雨 阅读(320) 评论(2) 推荐(0) 编辑