- 浏览: 37567 次
文章分类
- 全部博客 (41)
- 卧鸟个去 (2)
- Transform (2)
- Mathmatic (9)
- Plant-Tree (7)
- Data-Struct (12)
- Red-Black-Tree (1)
- Radix-Tree (1)
- Trie (2)
- String (4)
- BST (2)
- Amazing-Union-Find-Set (1)
- HDU (27)
- OJ (32)
- BFS (3)
- Pretty-Suffix-Array (2)
- POJ (6)
- Graceful-Segment-Tree (2)
- Geometry (6)
- Priority-Queue (2)
- Dynamic-Programing (1)
- DP (3)
- LCS (1)
- Convex-Hull (2)
- Triangulation (1)
- DFS (3)
- Combinatorial-Mathematics (2)
- Big-Number (1)
- Statistic (3)
- STL (1)
- Shortest-Path (3)
- ZOJ (1)
- Leftist-Tree (1)
- Prime (1)
- Binary-Index-Tree (1)
- (1)
- Stack (1)
- SPFA (0)
- CRT (1)
Count Color
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 21363 | Accepted: 6218 |
Description
Chosen Problem Solving and Program design as an optional course, you are required to solve all kinds of problems. Here, we get a new problem.
There is a very long board with length L centimeter, L is a positive integer, so we can evenly divide the board into L segments, and they are labeled by 1, 2, ... L from left to right, each is 1 centimeter long. Now we have to color the board - one segment with only one color. We can do following two operations on the board:
1. "C A B C" Color the board from segment A to segment B with color C.
2. "P A B" Output the number of different colors painted between segment A and segment B (including).
In our daily life, we have very few words to describe a color (red, green, blue, yellow…), so you may assume that the total number of different colors T is very small. To make it simple, we express the names of colors as color 1, color 2, ... color T. At the beginning, the board was painted in color 1. Now the rest of problem is left to your.
There is a very long board with length L centimeter, L is a positive integer, so we can evenly divide the board into L segments, and they are labeled by 1, 2, ... L from left to right, each is 1 centimeter long. Now we have to color the board - one segment with only one color. We can do following two operations on the board:
1. "C A B C" Color the board from segment A to segment B with color C.
2. "P A B" Output the number of different colors painted between segment A and segment B (including).
In our daily life, we have very few words to describe a color (red, green, blue, yellow…), so you may assume that the total number of different colors T is very small. To make it simple, we express the names of colors as color 1, color 2, ... color T. At the beginning, the board was painted in color 1. Now the rest of problem is left to your.
Input
First line of input contains L (1 <= L <= 100000), T (1 <= T <= 30) and O (1 <= O <= 100000). Here O denotes the number of operations. Following O lines, each contains "C A B C" or "P A B" (here A, B, C are integers, and A may be larger than B) as an operation defined previously.
Output
Ouput results of the output operation in order, each line contains a number.
Sample Input
2 2 4 C 1 1 2 P 1 2 C 2 2 2 P 1 2
Sample Output
2 1
好基础既线段树覆盖问题,LazyTag都唔洗用,直接贴代码…………
8711966 | GZHU1006100106 | 2777 | Accepted | 3244K | 360MS | C++ | 1523B | 2011-05-31 23:04:17 |
其实系小水题
发表评论
-
HDU 1075 What Are You Talking About
2011-08-04 11:00 866What Are You Talking About Tim ... -
HDU 1058 Humble Numbers
2011-08-02 15:55 1223Humble Numbers Time Limit: 200 ... -
HDU 2095 find your present (2)
2011-08-02 16:13 817find your present (2) Time Lim ... -
HDU 1022 Train Problem I
2011-08-02 21:00 1013Train Problem I Time Limit: 20 ... -
2142 HDU box
2011-08-02 21:21 763box Time Limit: 3000/1000 MS ( ... -
HDU 2151 Worm
2011-08-01 20:48 849Worm Time Limit: 1000/1000 MS ... -
HDU 2722 Here We Go(relians) Again
2011-08-02 00:06 1026Here We Go(relians) Again Time ... -
HDU 3791 二叉搜索树
2011-08-02 14:26 1208二叉搜索树 Time Limit: 20 ... -
PKU 2352 Stars
2011-07-31 21:47 1027Stars Time Limit: 1000MS ... -
PKU 2774 Long Long Message
2011-07-31 21:26 903Long Long Message Time Li ... -
HDU 2098 分拆素数和
2011-07-31 21:08 1062分拆素数和 Time Limit: 1000/1000 MS ... -
ZOJ 3512 Financial Fraud .
2011-07-31 20:49 1284Financial Fraud Time Limit: 3 ... -
HDU 1798 Tell me the area .
2011-07-31 20:47 1124Tell me the area Time Limit: 3 ... -
HDU 2962 Trucking .
2011-07-31 20:46 684Trucking Time Limit: 20000/100 ... -
HDU 1596 find the safest road .
2011-07-31 20:45 605find the safest road Time Limi ... -
HDU 2553 N皇后问题 .
2011-07-31 20:20 703N皇后问题 Time Limit: 2000/1000 MS ... -
HDU 1392 Surround the Trees .
2011-07-31 20:19 796Surround the Trees Time Limit: ... -
HDU 1234 开门人和关门人 .
2011-07-31 20:17 674开门人和关门人 Time Limit: 2000/1000 ... -
HDU 1316 How Many Fibs? .
2011-07-31 20:15 977How Many Fibs? Time Limit: 200 ... -
HDU 1028 Ignatius and the Princess III .
2011-07-31 20:13 757Ignatius and the Princess III ...
相关推荐
题目“2054-Color a Tree”是一个典型的树形结构优化问题,要求找到一种颜色节点的顺序,使得总成本最小。在这个问题中,每个节点都有一个“着色成本系数”Ci,节点i的着色成本是Ci乘以其被着色的时间Fi。时间在开始...
【标题】"pku.zip_PKU" 指的是一份与北京大学(Peking University, PKU)相关的压缩文件。从描述来看,这份压缩包包含了部分编程题目的代码,可能是学生或者爱好者在解决北京大学编程竞赛或课程作业时编写的。"pku"这...
"pku经典题目解题报告"这一标题揭示了文件内容的核心,它表明这是一份关于北京大学(PKU)编程竞赛或算法竞赛中的经典问题的解答集。通常,这样的报告会涵盖一系列在PKU历年比赛中出现的难题,包含了解题思路、算法...
pku1000 pku1000程序 解题报告
在编程竞赛的世界里,北京大学(PKU)的ACM团队以其高质量的题目和独特的解题思路闻名。"PKU-ACM.rar"这个压缩包包含了北大ACM题目的一些核心知识点,旨在帮助参赛者理解和掌握算法竞赛中的生命周期题目解法。本文将...
【标题】"ACM代码 之pku代码" 涉及的是在计算机科学领域中的算法竞赛编程,尤其是北京大学(Peking University, PKU)的ACM/ICPC(国际大学生程序设计竞赛)训练代码。这些代码是参赛者或教练为了准备这类竞赛而编写的,...
【标题】"PKU 课件 ppt 等 灰常强大" 指的是北京大学(PKU)的课程资料,其中包括了PPT演示文稿和其他相关文档资源,这些资料质量高、内容丰富,对学习者来说具有极高的价值。"灰常强大"这一网络用语表明这些课件...
标题 "pku acm 一些代码" 暗示了这是一个与北京大学(Peking University, 简称PKU)的ACM(国际大学生程序设计竞赛)相关的代码集合。在这个领域,参赛者通常需要解决算法问题,编写高效且优化的代码来求解数学、逻辑...
benchmark (PKU-MMD) for continuous multi-modality 3D human action understanding and cover a wide range of complex human activities with well annotated information. PKU-MMD contains 1076 long video ...
标题"Pku1664"很可能是指北京大学(Peking University)在某个编程竞赛或课程中的一道题目或项目,编号为1664。这道题目可能涉及到计算机科学的基础概念,尤其是算法和数据结构。描述中提到的是"Pku1664源代码",暗示...
8数码代码pku1077,300ms(哈希+广度搜索)
PKU 2339 Rock, Scissors, Paper 源代码
pku acm 1469 COURSES 代码 二分图的最大匹配的匈牙利算法 解题报告请访问:http://blog.csdn.net/china8848
北京大学pku2317 Questions and answers c++标程 文件名为2371.cpp
标题中的“pku1742.rar_pku 17_pku 1742 _报告及程序”表明这是一个与北京大学(Peking University, 简称PKU)相关的项目,项目编号可能是1742,内容包括了结题报告和程序代码。这个压缩包很可能是学生或研究人员提交...
标签部分进一步细化了内容:"pku acm_pku"再次强调这是北京大学ACM竞赛的资料,"pku__1709__crossword"可能是特定的题目标签,而"pku_acm"可能是北京大学ACM团队的标识。"visual_c"可能表示这些代码是使用C++语言,...
"p_acm"、"pku_acm"以及"pu_acm.pku_pku"等标签可能是用于分类或标识这些代码属于北京大学(Peking University, PKU)的ACM训练题目。"acm"一词重复出现,进一步强调了这是关于ACM编程竞赛的内容。 描述中提到"acmer...
标题中的“pku1088.rar_pku 10_pku 1088_poj 1088”指的是北京大学(Peking University, PKU)编程竞赛中的第1088题,也称为POJ(Peking University Online Judge)的1088题。这个题目在编程竞赛社区中通常有一个特定的...
分词训练用的pku训练集,主要是说明相似度计算的样例数据。