2013年5月14日

摘要: http://acm.hfut.edu.cn/OnlineJudge/个人感觉是挺有意思的一道题目,排序+离线处理+线段树统计。 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 20005 7 struct node{ 8 int lnum,rnum,num; 9 }setree[maxn<<2];10 struct 阅读全文
posted @ 2013-05-14 10:19 kim888168 阅读(142) 评论(0) 推荐(0) 编辑

2013年5月7日

摘要: 这题可以说是spoj GSSI的拓展题了,它求的是给定区间的最大连续和的两个端点下标。http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4146AC Code #include <cstdio>#include <cstring>#include <algorithm>using namespace std;#define lson l,m,rt<<1#define rson m+1, 阅读全文
posted @ 2013-05-07 23:44 kim888168 阅读(211) 评论(0) 推荐(0) 编辑

2013年5月6日

摘要: http://www.lightoj.com/volume_showproblem.php?problem=1089题意很简单,就是给出一些线段和一些点,求每个点被覆盖的次数。做的时候,二分写烂了,一直超时。晕~~~AC 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 50005 7 struct node{ 8 in 阅读全文
posted @ 2013-05-06 23:14 kim888168 阅读(220) 评论(0) 推荐(0) 编辑

2013年5月4日

摘要: http://codeforces.com/problemset/problem/85/Dhttp://acm.hdu.edu.cn/showproblem.php?pid=4288其实就是五棵线段树,我把它放在同一个数组里了,这样比较好处理,其中因为没有处理取模时会有负数的情况,最后让它加上一个很大的数才过的。(i+c+100000)%5AC Code 1 #include <cstdio> 2 #include <algorithm> 3 using namespace std; 4 #define lson l,m,rt<<1 5 #define rs 阅读全文
posted @ 2013-05-04 14:39 kim888168 阅读(185) 评论(0) 推荐(0) 编辑

2013年4月28日

摘要: 题目大意:给定两个长度为n(1~10^5)的数组a[]和数组b[],有两个操作。1: 1 x y k,令b[y+q]=a[x+q] (0<=q<k)2: 2 x, 问当前的b[x]的值。最多操作次数m为10^5.区间更新,单点查询。AC 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 100001 7 in 阅读全文
posted @ 2013-04-28 13:04 kim888168 阅读(162) 评论(0) 推荐(0) 编辑

2013年4月27日

摘要: http://codeforces.com/problemset/problem/159/C题意就是给你k个相同的字符串S,有n个操作,每次操作时把第p个字母c去掉,问最后得到的串。AC Code 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 using namespace std; 5 #define lson l,m,rt<<1 6 #define rson m+1,r,rt<<1|1 7 #define maxn 2000 8 struct n 阅读全文
posted @ 2013-04-27 23:13 kim888168 阅读(164) 评论(0) 推荐(0) 编辑

2013年4月19日

摘要: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3674离散化+线段树,还有 longlong。AC Code 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 using namespace std; 5 #define lson l,m,rt<<1 6 #define rson m+1,r,rt<<1|1 7 #define maxn 200005 8 struct node{ 9 阅读全文
posted @ 2013-04-19 23:16 kim888168 阅读(153) 评论(0) 推荐(0) 编辑

2013年4月17日

摘要: http://poj.org/problem?id=3321思路:将树形结构转为线性结构,用线段树统计苹果数。包含了线段树的两个基本操作。单点更新 区间查询。通过这道题掌握了将树形结构转为线性结构的方法。AC Code 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 using namespace std; 5 #define lson l,m,rt<<1 6 #define rson m+1,r,rt<<1|1 7 #define maxn 1000 阅读全文
posted @ 2013-04-17 23:26 kim888168 阅读(137) 评论(0) 推荐(0) 编辑

2013年4月9日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1520类型:树dp简单题AC Code 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 using namespace std; 5 #define maxn 6005 6 struct node{ 7 int y,next; 8 }ee[maxn<<1]; 9 int link[maxn],t;10 int f[maxn],g[maxn],val[maxn];11 void m 阅读全文
posted @ 2013-04-09 21:57 kim888168 阅读(120) 评论(0) 推荐(0) 编辑

2013年4月7日

摘要: http://acm.timus.ru/problem.aspx?space=1&num=1018类型:树dpAC Code 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 using namespace std; 5 int a[105][105],val[105]={0},tree[105][3],f[105][105],n; 6 void buildtree(int root) 7 { 8 int lr=0; 9 for(int i=1;i<=n;i++) 阅读全文
posted @ 2013-04-07 21:17 kim888168 阅读(275) 评论(0) 推荐(0) 编辑