hdu 4348 To the moon】的更多相关文章

To the moon Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 8372    Accepted Submission(s): 1986 Problem Description BackgroundTo The Moon is a independent game released in November 2011, it is…
版权声明:本文为博主原创文章,未经博主允许不得转载. hdu 4348 题意: 一个长度为n的数组,4种操作 : (1)C l r d:区间[l,r]中的数都加1,同时当前的时间戳加1 . (2)Q l r:查询当前时间戳区间[l,r]中所有数的和 . (3)H l r t:查询时间戳t区间[l,r]的和 . (4)B t:将当前时间戳置为t . 所有操作均合法 . 解法: 很明显是一道主席树的题 . 对于每一次区间加法都新建节点建一棵线段树,加个懒惰标记就行了,查询的话直接线段树区间求和 .…
链接: http://acm.hdu.edu.cn/showproblem.php?pid=4348 题意: 4种操作: C l r c   区间[l,r]加c,时间+1 Q l r    询问当前时间区间[l,r]的和 H l  r c  询问在时间t时,区间[l,r]的和 B x  回到时间x 思路: 涉及历史版本的询问,很容易想到主席树,然后尝试用线段树的思路用主席树写了下,疯狂WA,TLE,后面看了下其他人的博客....发现不能加pushdown操作,因为一般来说pushdown更新完当…
http://acm.hdu.edu.cn/showproblem.php?pid=4348 以前做的主席树没有做过在线修改的题做一下(主席树这种东西正经用法难道不是在线修改吗),标记永久化比较方便. 前面眼瞎爆了一次空间改过来之后交第二次奇迹一样a了,好久没有1A过了(泪). #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<cmath…
To the moon Problem Description BackgroundTo The Moon is a independent game released in November 2011, it is a role-playing adventure game powered by RPG Maker.The premise of To The Moon is based around a technology that allows us to permanently reco…
To the moonTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=88748#problem/I Description To The Moon is a independent game released in November 2011, it is a role-playing adventure game powered by RPG…
To the moon Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description BackgroundTo The Moon is a independent game released in November 2011, it is a role-playing adventure game powered by RPG Maker.The pr…
To the moon Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 4287    Accepted Submission(s): 923 Problem Description Background To The Moon is a independent game released in November 2011, it is…
题意:n个数 m次操作 操作分别为 C l r d: 把区间[l, r] 加 d Q l r : 查询区间[l, r]的和 H l r t: 查询时间t的时候[l, r]的和 B t: 回到时间t 思路:主席树区间修改,区间求和 + ; * maxn; int n, m; struct Node { int l, r; LL sum, add; } tr[maxnode]; int tail; LL a[maxn]; LL qL, qR, value; LL sum; #define lson…
题意: 给一个数组A[1] ~ A[n],有4种操作: Q l r询问l r区间和 C l r v给l r区间每个数加v H l r t询问第t步操作的时候l r区间和 B t返回到第t步操作 思路: 用主席树维护常规的线段树.我们之前已经知道了主席树单点更新,只要新增一条链就ok了,区间更新也有点差不多.我们每次要更新都用一个lazy标记,但是显然我们不能去更新那些已经存在的区间,那么我们就新建出所有要更新的区间.因为可持久化线段树有些结点不是自己的,所以我们不能直接简单的push up和pu…