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
2.代码
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 1e5 + 10;
#define lson l,m,rt<<1 //宏定义
#define rson m+1,r,rt<<1|1
int col[maxn << 2]; //懒惰标记
int sum[maxn << 2]; //区间的和
void PushUP(int rt)///更新节点
{
sum[rt] = sum[rt << 1] + sum[rt << 1 | 1];
}
void PushDown(int rt, int m)///下推标记 m表示左右子树总的数量
{
if (col[rt]) ///有标记
{
col[rt << 1] = col [rt << 1 | 1] = col[rt];//下推
sum[rt << 1] = (m - (m >> 1))*col[rt];
sum[rt << 1 | 1] = (m >> 1)*col[rt];
col[rt] = 0; ///清除标记
}
}
void build(int l, int r, int rt)//建树
{
col[rt] = 0;
sum[rt]= 1; ///初始值均为1
if (l == r) return;//到达叶节点 结束
int m = (l + r) >> 1;
build(lson); //左右递归
build(rson);
PushUP(rt); ///更新节点
}
void update(int L, int R,int c, int l, int r, int rt) ///区间更新
{
### 最后
> **面试题文档来啦,内容很多,485页!**
>
> **由于笔记的内容太多,没办法全部展示出来,下面只截取部分内容展示。**
>
> **[CodeChina开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频】](https://codechina.csdn.net/m0_60958482/java-p7)**
# 1111道Java工程师必问面试题
![](https://img-blog.csdnimg.cn/img_convert/6bcd2b43cf71cae7ecf3bc39ecb8b505.png)
**MyBatis 27题 + ZooKeeper 25题 + Dubbo 30题:**
![](https://img-blog.csdnimg.cn/img_convert/ac315279d11e6a5770d80bbaaf9151a8.png)
**Elasticsearch 24 题 +Memcached +** **Redis 40题:**
![](https://img-blog.csdnimg.cn/img_convert/b676212a0e3670e3c854812b83b5b90b.png)
**Spring 26 题+ 微服务 27题+ Linux 45题:**
![](https://img-blog.csdnimg.cn/img_convert/4fb582109a18f8289982722c04a8f638.png)
**Java面试题合集:**
** **Redis 40题:**
[外链图片转存中...(img-2OkvwuJH-1630548779833)]
**Spring 26 题+ 微服务 27题+ Linux 45题:**
[外链图片转存中...(img-gQbaZ1qX-1630548779835)]
**Java面试题合集:**
![](https://img-blog.csdnimg.cn/img_convert/62eff170f7fca31b2b4ca900a8398f37.png)