2013年2月7日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1171View Code 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 using namespace std; 5 int a[150005]; 6 struct mes{ 7 int v,num; 8 }op[55]; 9 void zeroonepack(int V,int v,int w)10 {11 for(int i=V;i>=v;i--)12 a[i]=max(a[i] 阅读全文
posted @ 2013-02-07 23:52 kim888168 阅读(129) 评论(0) 推荐(0) 编辑

2013年2月5日

摘要: Nladies attend the ball in the King's palace. Every lady can be described with three values: beauty, intellect and richness. King's Master of Ceremonies knows that ladies are very special creatures. If some lady understands that there is other lady at the ball which is more beautiful, smarte 阅读全文
posted @ 2013-02-05 20:13 kim888168 阅读(381) 评论(0) 推荐(0) 编辑

2013年1月27日

摘要: Problem Description:After inventing Turing Tree, 3xian always felt boring when solving problems about intervals, because Turing Tree could easily have the solution. As well, wily 3xian made lots of new problems about intervals. So, today, this sick thing happens again...Now given a sequence of N num 阅读全文
posted @ 2013-01-27 23:30 kim888168 阅读(147) 评论(0) 推荐(0) 编辑

2013年1月21日

摘要: 二维线段树题,求矩阵内的子矩阵中最小的值View Code 1 #include <cstdio> 2 #include <algorithm> 3 using namespace std; 4 #define lson l,m,rt<<1 5 #define rson m+1,r,rt<<1|1 6 #define maxn 301 7 int a[maxn][maxn]; 8 int setree[maxn<<2][maxn<<2]; 9 int n;10 void build1(int num1,int num2,i 阅读全文
posted @ 2013-01-21 19:25 kim888168 阅读(136) 评论(0) 推荐(0) 编辑

2013年1月19日

摘要: 思路:二维线段树求区域最值。值得注意的是在进行Q操作时可能H1>H2,A1>A2.所以要swap.View Code 1 #include <cstdio> 2 #include <algorithm> 3 using namespace std; 4 #define lson l,m,rt<<1 5 #define rson m+1,r,rt<<1|1 6 #define maxn1 1002 7 #define maxn2 102 8 struct node 9 { 10 int subsetree[maxn1*3]; 11 }s 阅读全文
posted @ 2013-01-19 23:28 kim888168 阅读(140) 评论(0) 推荐(0) 编辑
 
摘要: 题意:有一个n*n(n<=1000) 的矩阵,开始时全为零,现在有两种操作(1)"C x1 y1 x2 y2“表示将以(x1,y1)为左上顶点,以(x2,y2)为右下顶点的长方形区域内的值全部取反。(2)”Q x y“表示点(x,y)的值。具体思路参考国家集训队2009论文集浅谈信息学竞赛中的0和1“;我自己用的是二维线段树。View Code 1 #include <cstdio> 2 #include <algorithm> 3 using namespace std; 4 #define maxn 1002 5 #define lson l,m,r 阅读全文
posted @ 2013-01-19 16:50 kim888168 阅读(113) 评论(0) 推荐(0) 编辑

2013年1月3日

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4339题意:给出两个字符串S1,S2,进行两种操作:(1)1 a i c 在字符串Sa中,将Sa[i]变成c(2)2 i,求从i下标开始的最长匹配长度。View Code 1 #include <stdio.h> 2 #include <string.h> 3 #define lson l,m,rt<<1 4 #define rson m+1,r,rt<<1|1 5 #define maxn 1000001 6 struct node 7 { 8 in 阅读全文
posted @ 2013-01-03 23:18 kim888168 阅读(137) 评论(0) 推荐(0) 编辑

2012年12月19日

摘要: 用线段树保存区间最大经验值,最大级别,最小升级系数,和lazy标记。若区间内有hero要升级,则更新下去。否则直接更新区间信息。思路是参照下面的大牛:http://blog.csdn.net/weiguang_123/article/details/8095362View Code 1 #include <stdio.h> 2 #define lson l,m,rt<<1 3 #define rson m+1,r,rt<<1|1 4 #define maxn 10005 5 int n,k,m; 6 int level[15]={ 7 0,0 8 }; 9 阅读全文
posted @ 2012-12-19 22:11 kim888168 阅读(122) 评论(0) 推荐(0) 编辑

2012年12月12日

摘要: 统计覆盖两次及以上的面积和。思路:区间更新。建立线段树时,用cover域表示区间覆盖次数,once域表示区间被覆盖一次的长度,more域表示区间被覆盖两次及以上的长度。用时250ms,rank11还是比较快的。View Code 1 #include <cstdio> 2 #include <algorithm> 3 using namespace std; 4 #define lson l,m,rt<<1 5 #define rson m+1,r,rt<<1|1 6 #define maxn 2005 7 struct node 8 { 9 d 阅读全文
posted @ 2012-12-12 15:12 kim888168 阅读(158) 评论(0) 推荐(0) 编辑

2012年12月9日

摘要: 题意:给出n个数x1,x2...xn.进行m次操作,每次给出一个区间[l ,r].求出xi属于区间[l, r]使得该区间的每个数与xi的差之和最小,并求出该和。思路:划分树。View Code 1 #include <cstdio> 2 #include <algorithm> 3 using namespace std; 4 #define lson l,m,rt+1 5 #define rson m+1,r,rt+1 6 #define maxn 100001 7 struct node 8 { 9 int val[maxn]; 10 int num[m... 阅读全文
posted @ 2012-12-09 15:48 kim888168 阅读(135) 评论(0) 推荐(0) 编辑