上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 30 下一页
摘要: 题目连接:http://www.spoj.com/problems/LGLOVE/题意:给出n个初始序列a[1],a[2],...,a[n],b[i]表示LCM(1,2,3,...,a[i]),即1~a[i]的最小公倍数 然后给出三种操作,注意:0#include #include #... 阅读全文
posted @ 2013-11-16 09:26 辰曦~文若 阅读(846) 评论(0) 推荐(0)
摘要: 参考链接:http://blog.csdn.net/dyx404514/article/details/8817717写的很详细,这里就不再赘述,附上我的代码。#include #include #include #define lson rt=m的数的位置,还是查找=l的最近的数的位置,此时mark=1; 查找r的时候,由于r可能不存在,所以我们查找的时候需要查找1){ mid=(l+r)>>1; if(hashval[mid]>1; build(lson); build(rson); pushUp(tree[rt],tree[... 阅读全文
posted @ 2013-11-15 20:20 辰曦~文若 阅读(330) 评论(0) 推荐(0)
摘要: 题目连接:http://www.spoj.com/problems/CNTPRIME/#include #include #include #include #define lson rt>1; build(lson); build(rson); pushUp(rt);}void update(int rt,int L,int R,int l,int r,int v){ if(l>1; if(lmid) update(rson,l,r,v); pushUp(rt);}int query(int rt,int L,int R,int l,int ... 阅读全文
posted @ 2013-11-13 09:23 辰曦~文若 阅读(376) 评论(0) 推荐(0)
摘要: #include #include #include #define lson rtrs.m1){ rt.m1=ls.m1; if(ls.m2>=rs.m1) rt.m2=ls.m2; else rt.m2=rs.m1; } else if(ls.m1==rs.m1){ rt.m1=rt.m2=ls.m1; } else{ rt.m1=rs.m1; if(rs.m2>=ls.m1) rt.m2=rs.m2; ... 阅读全文
posted @ 2013-11-12 21:16 辰曦~文若 阅读(355) 评论(0) 推荐(0)
摘要: #include #include #include #define lson rt>1; build(lson); build(rson); pushUp(rt);}void pushDown(Node &rt,Node &ls,Node &rs){ if(rt.flag){ ls.flag=!ls.flag; //一开始将ls和rs的flag直接设为true了,导致WA。。。 rs.flag=!rs.flag; swap(ls.num0,ls.num1); swap(rs.num0,rs.num1); ... 阅读全文
posted @ 2013-11-12 21:15 辰曦~文若 阅读(534) 评论(0) 推荐(0)
摘要: #include #include #include #include #define lson rt>1; build(lson); build(rson);}void pushDown(int rt){ if(tree[rt].lazy){ tree[rt>1; if(lmid) update(rson,l,r,val);}//单点查询cntvoid query1(int rt,int L,int R){ if(L==R){ cnt[L]+=tree[rt].add; return; } pu... 阅读全文
posted @ 2013-11-12 21:06 辰曦~文若 阅读(362) 评论(0) 推荐(0)
摘要: 题目连接:http://www.spoj.com/problems/MULTQ3/#include #include #include #define lson rt>1; build(lson); build(rson);}void pushUp(int rt){ tree[rt].num0=tree[rtnum1 num1->num2 num2->num0 */ int tmp; tmp=ls.num0; ls.num0=ls.num2; ls.num2=ls.num1; ... 阅读全文
posted @ 2013-11-11 20:31 辰曦~文若 阅读(455) 评论(0) 推荐(0)
摘要: 题意:一条线上有n个点,D x是破坏这个点,Q x是表示查询x所在的最长的连续的点的个数,R是恢复上一次破坏的点。思路:这题的关键是查询。 将被毁的村庄看成空位,当查询某个点的时候,如果我们知道它左边最近的空位a和右边最近的空位b, 那么我们只要查询区间[a,b]中的个数,即为答案,因为[a,b]之间不可能有空位存在了。 那么如何获取这样的a和b呢,这个就和HDU 4302 Holedox Eating 差不多了。 对每个节点,存储该区间中 空位的最大位置 和 空位的最小位置,还有 该区间村庄的个数。 这样当我们查询某点x的时候,那么我们... 阅读全文
posted @ 2013-11-11 18:18 辰曦~文若 阅读(239) 评论(0) 推荐(0)
摘要: 费了我一天半的时间,到处debug,后来才发现,主要是建树的时候只在叶子节点对lazy1和lazy2进行初始化了,父节点都没初始化。。。晕。 具体见代码吧。#include #include #include #define lson rt>1; build(lson); build(rson); pushUp(tree[rt],tree[rt>1; if(lmid) update(rson,l,r,c); pushUp(tree[rt],tree[rt>1; if(lmid) updatexor(rson,l,r); ... 阅读全文
posted @ 2013-11-10 22:35 辰曦~文若 阅读(189) 评论(0) 推荐(0)
摘要: #include #include #include #define lson rt>1; build(lson); build(rson); pushUp(rt);}void update(int rt,int L,int R,int l,int r,long long val){ if(l>1; if(lmid) update(rson,l,r,val); pushUp(rt);}long long query(int rt,int L,int R,int l,int r){ long long ret=0; if(l>1; ... 阅读全文
posted @ 2013-11-07 20:52 辰曦~文若 阅读(150) 评论(0) 推荐(0)
上一页 1 ··· 17 18 19 20 21 22 23 24 25 ··· 30 下一页