HDU 4973 A simple simulation problem.(線段樹)
來源:程序員人生 發(fā)布時間:2014-10-12 16:02:33 閱讀次數(shù):2359次
題目大意:D表示在區(qū)間x,y內(nèi)所有的元素擴(kuò)充一倍;Q表示查詢在這個下表以內(nèi)的數(shù)字最多的個數(shù)為多少。
如:1,2,3.D 1 3 之后就變成了 1 1 2 2 3 3.Q 1 4 輸出 2.
解題思路:每個節(jié)點記錄兩個信息:最大值的個數(shù)以及這個點一共有多少個數(shù)字。
A simple simulation problem.
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 580 Accepted Submission(s): 227
Problem Description
There are n types of cells in the lab, numbered from 1 to n. These cells are put in a queue, the i-th cell belongs to type i. Each time I can use mitogen to double the cells in the interval [l, r]. For instance, the original queue
is {1 2 3 3 4 5}, after using a mitogen in the interval [2, 5] the queue will be {1 2 2 3 3 3 3 4 4 5}. After some operations this queue could become very long, and I can’t figure out maximum count of cells of same type. Could you help me?
Input
The first line contains a single integer t (1 <= t <= 20), the number of test cases.
For each case, the first line contains 2 integers (1 <= n,m<= 50000) indicating the number of cell types and the number of operations.
For the following m lines, each line represents an operation. There are only two kinds of operations: Q and D. And the format is:
“Q l r”, query the maximum number of cells of same type in the interval [l, r];
“D l r”, double the cells in the interval [l, r];
(0 <= r
生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈
------分隔線----------------------------
------分隔線----------------------------