会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
辰曦~文若
We all have something special. Something we are destined to do. Something for which we were born.
博客园
首页
新随笔
联系
管理
订阅
上一页
1
···
17
18
19
20
21
22
23
24
25
···
30
下一页
2013年11月16日
SPOJ LGLOVE 7488 LCM GCD Love (区间更新,预处理出LCM(1,2,...,n))
摘要: 题目连接: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)
2013年11月15日
codeforces 295E Yaroslav and Points (离线操作+离散化+区间合并)
摘要: 参考链接: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)
2013年11月13日
SPOJ CNTPRIME 13015 Counting Primes (水题,区间更新,求区间的素数个数)
摘要: 题目连接: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)
2013年11月12日
SPOJ 3693 Maximum Sum(水题,记录区间第一大和第二大数)
摘要: #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)
SPOJ 7259 Light Switching (水题,区间01取反)
摘要: #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)
CF 295A Greg and Array (两次建树,区间更新,单点查询)
摘要: #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)
2013年11月11日
SPOJ MULTQ3 7299 Multiples of 3 (区间更新)
摘要: 题目连接: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)
HDU 1540 / POJ 2892 Tunnel Warfare (单点更新,区间合并,求包含某点的最大连续个数)
摘要: 题意:一条线上有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)
2013年11月10日
HDU 3397 Sequence operation (区间合并,操作比较多)
摘要: 费了我一天半的时间,到处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)
2013年11月7日
POJ 3468 A Simple Problem with Integers(线段树区间更新,模板题,求区间和)
摘要: #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
下一页
公告