/*
区间更新
*/
#include <cstdio>
#include <algorithm>
using namespace std;
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
const int maxn = ;
int h , w , n;
int col[maxn<<];
int sum[maxn<<];
void PushUp(int rt) {
sum[rt] = sum[rt<<] + sum[rt<<|];
}
void PushDown(int rt,int m) {
if (col[rt]) {
col[rt<<] = col[rt<<|] = col[rt];
sum[rt<<] = (m - (m >> )) * col[rt];
sum[rt<<|] = (m >> ) * col[rt];
col[rt] = ;
}
}
void build(int l,int r,int rt) {
col[rt] = ;
sum[rt] = ;
if (l == r) return ;
int m = (l + r) >> ;
build(lson);
build(rson);
PushUp(rt);
}
void update(int L,int R,int c,int l,int r,int rt) {
if (L <= l && r <= R) {
col[rt] = c;
sum[rt] = c * (r - l + );
return ;
}
PushDown(rt , r - l + );
int m = (l + r) >> ;
if (L <= m) update(L , R , c , lson);
if (R > m) update(L , R , c , rson);
PushUp(rt);
}
int main() {
int T , n , m;
scanf("%d",&T);
for (int cas = ; cas <= T ; cas ++) {
scanf("%d%d",&n,&m);
build( , n , )
while (m --) {
int a , b , c;
scanf("%d%d%d",&a,&b,&c);
update(a , b , c , , n , );
}
printf("Case %d: The total value of the hook is %d.\n",cas , sum[]);
}
return ;
}

hdu1698的更多相关文章

  1. hdu1698(线段树的区间替换)

    HDU1698 #include <bits/stdc++.h> using namespace std; #define Maxn 1001000*4 struct Node{ int ...

  2. hdu1698 线段树区间更新

    Just a Hook Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Tota ...

  3. 线段树---成段更新hdu1698 Just a Hook

    hdu1698 Just a Hook 题意:O(-1) 思路:O(-1) 线段树功能:update:成段替换 (由于只query一次总区间,所以可以直接输出1结点的信息) 题意:给一组棍子染色,不同 ...

  4. HDU1698 Just a Hook —— 线段树 区间染色

    题目链接:https://vjudge.net/problem/HDU-1698 In the game of DotA, Pudge’s meat hook is actually the most ...

  5. Just a Hook(HDU1698 线段树的简单应用)

    Just a Hook Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Prob ...

  6. HDU-1698 JUST A HOOK 线段树

    最近刚学线段树,做了些经典题目来练手 Just a Hook Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (J ...

  7. HDU1698 Just a Hook

    Description In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of t ...

  8. hdu-------(1698)Just a Hook(线段树区间更新)

    Just a Hook Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  9. HDU1698 Just a Hook (区间更新)

    Just a Hook Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  10. 【线段树成段更新-模板】【HDU1698】Just a Hook

    题意 Q个操作,将l,r 的值改为w 问最后1,n的sum 为多少 成段更新(通常这对初学者来说是一道坎),需要用到延迟标记(或者说懒惰标记),简单来说就是每次更新的时候不要更新到底,用延迟标记使得更 ...

随机推荐

  1. Django 日志配置按日期滚动

    记录下Django关于日期的配置,以及如何根据日期滚动切割日志的问题. 配置的源码在githun上 https://github.com/blackmatrix7/django-examples/tr ...

  2. 深入flask中的request

    缘起 在使用flask的时候一直比较纳闷request是什么原理,他是如何保证多线程情况下对不同请求参数的隔离的. 准备知识 在讲request之前首先需要先理解一下werkzeug.local中的几 ...

  3. Simple Question

    一.你会在时间序列数据集上使用什么交叉验证技术?是用k倍? 答:都不是.对于时间序列问题,k倍可能会很麻烦,因为第4年或第5年的一些模式有可能跟第3年的不同,而我们最终可能只是需要对过去几年的进行验证 ...

  4. Redis 安全配置

    1.禁止一些高危命令 修改 redis.conf 文件,添加 rename-command FLUSHALL "" rename-command FLUSHDB "&qu ...

  5. Linux命令之rmdir

    rmdir命令 用处:删除文件夹 用法:在终端中输入rmdir加上要删除的文件夹的名字 示例: (我要删除shuyunquan这个文件夹)

  6. mac下chrome快捷键

    打开开发者工具:alt + command + I: 打开“JavaScript 控制台”:⌘-Option-J: 打开当前网页的源代码:⌘-Option-U: 刷新页面:command + R: m ...

  7. CM记录-CDH故障修复处理记录

    CDH大数据集群修复记录 1)cm web打不开,查看监听7180端口产生了很多进程,于是kill进程:重启cloudera-cmf-server服务,几秒钟就挂了,查看cloudera-scm-se ...

  8. 枚举专项练习_Uva725(Division)_Uva11059(Maximun Product)

    //Uva725 #include <iostream> #include <cstring> #include <cstdlib> #include <cs ...

  9. jquery扩展代码少的分页bar

    直接上图,上代码了,代码量少,不解释那么多了 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" ...

  10. Android学习笔记——Content Provider(一)

    Content Provider是Android系统四大组件之一: 官方的定义是:A Content Provider manages access to a central repository o ...