题意:
将一段长为L的板子染色,板子可分为编号为1,2,3...L的L段,总共有O次操作,操作有两种:1.将A到B区间染为颜色C 2.询问A到B区间有多少种颜色。颜色从1到T编号,不超过30种。
思路:1.由于颜色不超过30种,所以可以考虑位运算,每一位代表一种颜色,一个32位整数就可以存储所有的颜色状态。
2.对于操作一,就是区间更新操作,需要用lazy操作,当需要更新子节点...
分类:
其他好文 时间:
2015-05-26 09:21:26
阅读次数:
150
原题链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1798线段树区间更新: 1. 区间同同时加上一个数 2. 区间同时乘以一个数 1 #include 2 #include 3 #include 4 #include 5 #define lc ...
分类:
其他好文 时间:
2015-05-25 22:06:08
阅读次数:
148
区间更新
区间求和
思想:懒处理,对于区间更新不需要将更新具体到叶子结点,只在需要更新的时候,再细化处理。代码:import java.util.Scanner;class SegmentTree{
class Node{
int left;
int right;
long sum;
long addValue;
}...
分类:
其他好文 时间:
2015-05-23 20:08:05
阅读次数:
130
这道题搞了好久,其实坑点挺多。。网上找了许多题解,发现思路其实都差不多,所以就不在重复了。推荐一篇比较好的题解,请戳这。另外,如果因为可能要更新多次,但最终查询只需要一次,所以没有写pushup函数,仅有一个pushdown。 1 #include 2 3 const int maxn =...
分类:
其他好文 时间:
2015-04-28 13:57:32
阅读次数:
110
有m个操作,每个操作 X Y Z是将区间[X, Y]中的所有的数全部变为Z,最后询问整个区间所有数之和是多少。区间更新有一个懒惰标记,set[o] = v,表示这个区间所有的数都是v,只有这个区间被分开的时候再往下传递。 1 #include 2 3 const int maxn = 10000.....
分类:
其他好文 时间:
2015-04-26 16:25:29
阅读次数:
157
Mayor's postersTime Limit: 1 SecMemory Limit: 256 MB题目连接http://poj.org/problem?id=2528DescriptionThe citizens of Bytetown, AB, could not stand that th...
分类:
其他好文 时间:
2015-04-21 19:56:12
阅读次数:
120
A Simple Problem with Integers
Time Limit: 5000MS
Memory Limit: 131072K
Total Submissions: 70442
Accepted: 21723
Case Time Limit: 2000MS
Description
You have N i...
分类:
其他好文 时间:
2015-04-14 19:44:21
阅读次数:
127
Count Color
Time Limit: 1000MS
Memory Limit: 65536K
Total Submissions: 37647
Accepted: 11315
Description
Chosen Problem Solving and Program design as an optional cour...
分类:
其他好文 时间:
2015-04-14 19:42:17
阅读次数:
119
Just a Hook
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 19862 Accepted Submission(s): 9964
Problem Description
In the game o...
分类:
其他好文 时间:
2015-04-09 08:57:18
阅读次数:
157
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1698Let us number the consecutive metallic sticks of the hook from 1 to N. For each operation, Pudge ca...
分类:
其他好文 时间:
2015-04-03 23:45:47
阅读次数:
150