博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU1698:Just a Hook(线段树区间更新)
阅读量:7098 次
发布时间:2019-06-28

本文共 1862 字,大约阅读时间需要 6 分钟。

Problem Description
In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the same length.
Now Pudge wants to do some operations on the hook.
Let us number the consecutive metallic sticks of the hook from 1 to N. For each operation, Pudge can change the consecutive metallic sticks, numbered from X to Y, into cupreous sticks, silver sticks or golden sticks.
The total value of the hook is calculated as the sum of values of N metallic sticks. More precisely, the value for each kind of stick is calculated as follows:
For each cupreous stick, the value is 1.
For each silver stick, the value is 2.
For each golden stick, the value is 3.
Pudge wants to know the total value of the hook after performing the operations.
You may consider the original hook is made up of cupreous sticks.
 

 

Input
The input consists of several test cases. The first line of the input is the number of the cases. There are no more than 10 cases.
For each case, the first line contains an integer N, 1<=N<=100,000, which is the number of the sticks of Pudge’s meat hook and the second line contains an integer Q, 0<=Q<=100,000, which is the number of the operations.
Next Q lines, each line contains three integers X, Y, 1<=X<=Y<=N, Z, 1<=Z<=3, which defines an operation: change the sticks numbered from X to Y into the metal kind Z, where Z=1 represents the cupreous kind, Z=2 represents the silver kind and Z=3 represents the golden kind.
 

 

Output
For each case, print a number in a line representing the total value of the hook after the operations. Use the format in the example.
 

 

Sample Input
1 10 2 1 5 2 5 9 3
 

 

Sample Output
Case 1: The total value of the hook is 24.
 

 

题意:胖子有一条大jb,大JB由n个小JB组成,每次操作将一个区间的小JB变成金银铜三者之一,最后取出所有区间的JB总价值

思路:和刷气球差不多意思了,简单的区间更新,无需更新到叶子节点,防止超时

 

转载地址:http://exhql.baihongyu.com/

你可能感兴趣的文章
使用mysql触发器脚本,解决流水数据的添加。
查看>>
SIP and RTP Stack
查看>>
Activity间用Intent、Bundle、onActivityResult进行传值
查看>>
在创建窗口句柄之前,不能在控件上调用 Invoke 或 BeginInvoke。
查看>>
AC自动机 - 多模式串的匹配运用 --- HDU 3065
查看>>
B-树学习笔记
查看>>
黑客发布iOS 4.1永久越狱程序
查看>>
T-Mobile证实数据泄露 但客户暂无风险
查看>>
使用 MEF 公开 Silverlight“.NET研究” MVVM 应用程序中的接口
查看>>
Random Sequence 2011ACM福州赛区网络赛
查看>>
node.js 文件操作
查看>>
异常不可用于逻辑处理
查看>>
小米手机如期而至
查看>>
STM32 RCC实验 MCO脚输出时钟波形
查看>>
Flash 最小化,帧速变慢的问题
查看>>
java对redis的基本操作(一)
查看>>
基因组印记
查看>>
34个漂亮的应用程序后台管理界面(系列三)
查看>>
double free or corruption (!prev): 0x080644c8 ***
查看>>
在VMware上搭建iPhone开发环境(转)
查看>>