- 浏览: 36039 次
文章分类
- 全部博客 (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 834What Are You Talking About Tim ... -
HDU 1058 Humble Numbers
2011-08-02 15:55 1171Humble Numbers Time Limit: 200 ... -
HDU 2095 find your present (2)
2011-08-02 16:13 766find your present (2) Time Lim ... -
HDU 1022 Train Problem I
2011-08-02 21:00 995Train Problem I Time Limit: 20 ... -
2142 HDU box
2011-08-02 21:21 735box Time Limit: 3000/1000 MS ( ... -
HDU 2151 Worm
2011-08-01 20:48 787Worm Time Limit: 1000/1000 MS ... -
HDU 2722 Here We Go(relians) Again
2011-08-02 00:06 968Here We Go(relians) Again Time ... -
HDU 3791 二叉搜索树
2011-08-02 14:26 1160二叉搜索树 Time Limit: 20 ... -
PKU 2352 Stars
2011-07-31 21:47 986Stars Time Limit: 1000MS ... -
PKU 2774 Long Long Message
2011-07-31 21:26 864Long Long Message Time Li ... -
HDU 2098 分拆素数和
2011-07-31 21:08 1015分拆素数和 Time Limit: 1000/1000 MS ... -
ZOJ 3512 Financial Fraud .
2011-07-31 20:49 1230Financial Fraud Time Limit: 3 ... -
HDU 1798 Tell me the area .
2011-07-31 20:47 1071Tell me the area Time Limit: 3 ... -
HDU 2962 Trucking .
2011-07-31 20:46 641Trucking Time Limit: 20000/100 ... -
HDU 1596 find the safest road .
2011-07-31 20:45 572find the safest road Time Limi ... -
HDU 2553 N皇后问题 .
2011-07-31 20:20 662N皇后问题 Time Limit: 2000/1000 MS ... -
HDU 1392 Surround the Trees .
2011-07-31 20:19 758Surround the Trees Time Limit: ... -
HDU 1234 开门人和关门人 .
2011-07-31 20:17 644开门人和关门人 Time Limit: 2000/1000 ... -
HDU 1316 How Many Fibs? .
2011-07-31 20:15 945How Many Fibs? Time Limit: 200 ... -
HDU 1028 Ignatius and the Princess III .
2011-07-31 20:13 718Ignatius and the Princess III ...
相关推荐
花了老长时间琢磨。。终于还是过了,长了很多经验,写的简单易懂。。
pku部分题代码,不多,试一下怎么上传文件!
pku1000 pku1000程序 解题报告
pku经典题目解题报告 pku经典题目解题报告
pku1664源代码
PKU JudgeOnline FAQ 中文版 常见问题解答
8数码代码pku1077,300ms(哈希+广度搜索)
ppt word PKU 课件 五星级灰常强大
ACM代码 北大pku。 搞ACM的可以参考一下。代码还是挺规范的。有接近150道题目的代码。
PKU 2339 Rock, Scissors, Paper 源代码
有一些代码是pku上的,希望大家看后给我留言,看看我的代码那里有问题??
pku acm 1469 COURSES 代码 二分图的最大匹配的匈牙利算法 解题报告请访问:http://blog.csdn.net/china8848
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 ...
这是关于PKU上的题目分类 很详细 适合不同水平的童鞋们参考
北京大学pku2317 Questions and answers c++标程 文件名为2371.cpp
我写的解题报告,关于度限制生成树的 网址:http://acm.pku.edu.cn/JudgeOnline/problem?id=1639<br>题目:Picnic Planning 来源:East Central North America 2000
PKU的oj分类 可以通过分类进行练习~~~
分词训练用的pku训练集,主要是说明相似度计算的样例数据。
pku acm 1042 贪心法