/*
区间更新
*/
#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. Java ExecutorService四种线程池的例子与说明

    1.new Thread的弊端 执行一个异步任务你还只是如下new Thread吗? new Thread(new Runnable() { @Override public void run() { ...

  2. wkhtmltopdf 安装过程不包含php扩展部分

    Qt Webkit HTML Converter Install wkhtmltopdf This page documents installation of wkhtmltopdf on Gent ...

  3. 学习windows编程 day4 之 绘制随机矩形和peekMessage

    #include <windows.h> #include <strsafe.h> LRESULT CALLBACK WndProc(HWND hwnd, UINT messa ...

  4. vue确认密码

    rules: { pwd:[{ required:true, message:'创建密码',trigger:'blur' }], cpwd:[{ required:true,message:'确认密码 ...

  5. filebeat多个key

    filebeat.prospectors:- type: log paths: - D:\logs\iis\W3SVC2\*.log exclude_lines: ['^#'] multiline: ...

  6. Calendar add 方法 和set方法

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Calendar c = Calendar. ...

  7. dubbo面试问题

    为什么用微服务: 为什么zookeeper能作为注册中心: 使用分布式碰到的bug, zookeeper有集群吗?怎么实现的: zookeeper宕机还能访问吗: 服务失效踢出zookeeper中临时 ...

  8. FZU - 1688 Binary land

    题目链接  Problem 1688 Binary land Accept: 72    Submit: 171Time Limit: 1000 mSec    Memory Limit : 3276 ...

  9. HTML5的manifest 本地离线缓存

    下面直接放测试代码: index.html <!DOCTYPE html> <html manifest="m.manifest"> <head> ...

  10. u-boot移植(三)---修改前工作:代码流程分析2

    一.vectors.S 1.1 代码地址 vectors.S (arch\arm\lib) 1.2 流程跳转 跳转符号 B 为 start.S 中的 reset 执行代码,暂且先不看,先看看 vect ...