#include<bits/stdc++.h>
using namespace std;
const int MAXN=100005;
#define lson k<<1
#define rson k<<1|1
struct tree
{
int l,r;
int sum;
int tag;
int mid(){ return (l+r)>>1; }
}node[MAXN<<2];
void pushup(int k)
{
node[k].sum=node[lson].sum+node[rson].sum;
}
void pushdown(int k,int m)
{
if(node[k].tag)
{
node[lson].tag=node[k].tag;
node[rson].tag=node[k].tag;
node[lson].sum=node[k].tag*(m-(m>>1));
node[rson].sum=node[k].tag*(m>>1);
node[k].tag=0;
}
}
void build(int l,int r,int k)
{
node[k].l=l;
node[k].r=r;
node[k].tag=0;
node[k].sum=1;
if(l==r) return ;
int mid=node[k].mid();
build(l,mid,lson);
build(mid+1,r,rson);
pushup(k);
}
void update(int l,int r,int col,int k)
{
int m=node[k].r-node[k].l+1;
if(l<=node[k].l&&r>=node[k].r)
{
node[k].tag=col;
node[k].sum=m*col;
return ;
}
pushdown(k,m);
int mid=node[k].mid();
if(l>mid) update(l,r,col,rson);
else if(r<=mid) update(l,r,col,lson);
else
{
update(l,mid,col,lson);
update(mid+1,r,col,rson);
}
pushup(k);
}
int main()
{
int t;
int ca=1;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
int q;
build(1,n,1);
scanf("%d",&q);
while(q--)
{
int l,r,v;
scanf("%d %d %d",&l,&r,&v);
update(l,r,v,1);
}
printf("Case %d: The total value of the hook is %d.\n",ca++,node[1].sum);
}
return 0;
}
相关推荐
adams案例分析_案例1(麦弗逊悬架子系统创建)
本文字数3292字83图,建议阅读时间26分钟首先看下案例1的麦弗逊悬架数模结构就不细讲了,从数模上主要是获取硬点坐标(铰接点、安装点、参考点)及大部件结构(副车架、摆臂、转向节等实际运动过程中会产生变形的部件,在ADAMS Car中我们就可以用柔性体来搭建)再来回顾下上一篇讲到的模型元素1、Hardpoint——硬点(只有位置没有方向)2、Parameter Variable——参数...
Just a Hook (线段树)
/*题意:输入一个T表示有几组测试数据 输入n表示有几块sticks 输入k表示有几次操作 a,b,c表示把区间[a,b]的值改成c 求最后区间[1,n]所有值的和*/ #include #include #include using namespace std; struct node { int l, r, sum; int mark; }dp[100005<<2]; void C
arcgis select by attributes一次选多个_视频:如何基于ArcGIS与GeoDa求莫兰指数和绘制莫兰散点图?...
莫兰指数是全域莫兰指数(Global Moran's I)的简称,是澳大利亚统计学家帕特里克·阿尔弗雷德·皮尔斯·莫兰(Patrick Alfred Pierce Moran),在1950年提出的。详细介绍,如下:莫兰指数取值范围在-1.0至1.0之间。当Moran's I >0时,表示空间正相关性,其值越大,空间相关性越明显;当Moran's I <0时,表示空间负相关性...
【线段树】Just a Hook
博客主页: https://blog.csdn.net/qq_50285142 欢迎点赞????收藏✨关注❤留言 ???? 如有错误,敬请指正 ????虽然生活很难,但我们也要一直走下去???? 题目链接 题意: n个小棒,初始都为铜质,每次操作可以选择一个区间将所有的小棒改变成同一个质地(金银铜),求所有小棒的总价值,默认金银铜的价值分别为3,2,1 【线段树】 区间修改的操作,add标记区间的单个小棒的价值,每次访问到一个区间就要把信息向下传递,同时总数进行改变(pushdown操作) 最后直
Cisco Packet Tracer 7.3免登录技巧:3种方法快速跳过注册界面(附详细截图)
本文针对Cisco Packet Tracer 7.3启动时遇到的登录界面问题,提供了三种合法高效的解决方案。详细介绍了如何利用官方访客模式快速启动、注册思科账号实现一劳永逸登录,以及通过调整本地安装配置优化启动流程,帮助网络学习者与备考者绕过繁琐步骤,快速进入实验环境。
从GEFCom到UCI:手把手教你构建电力负荷时空预测模型(Python版)
本文详细介绍了如何从GEFCom到UCI数据集构建电力负荷时空预测模型(Python版),涵盖数据集解析、时空特征工程、模型架构设计及工业部署优化。通过多任务图神经网络(MTGNN)实现高精度预测,并结合边缘计算和在线学习机制提升实际应用效果,为能源管理系统提供可靠解决方案。
(POJ1698)Just a Hook(又是线段树)
又做了几道线段树题目,挑了一道设计到区间修改和区间读取的题目发了上来。本次写线段树的时候就有参照大神的模版,明显代码的清晰程度高了很多。这道题目并没有什么弯弯绕绕,就是一个明显的线段树裸体,不需要经过什么奇怪的分析。 在本题中,我设定线段存在两个参数cnt和chg。其中cnt代表了当前线段的元素和,而chg是一线段的修改标记,意味着当前线段已经被修改了1、2、3.,本题中,由于参照了大神的模版,代
ESP32设备驱动-TM1637-驱动4位7段数码管
TM1637是一款带键盘扫描接口的LED(发光二极管显示器)驱动控制专用电路,内部集成了MCU数字接口、数据锁存、LED高压驱动、键盘扫描等功能。 TM1637使用DIP20/SOP20封装,主要适用于电磁炉、微波炉、小家电的显示驱动。
Just a Hook
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 Pud...
【异常】OpenClaw报错 400 Total tokens of image and text exceed max message tokens. Request
OpenClaw报错400(Token超限)解决方案摘要 该报错因文本/图片总Token数超过模型限额导致,常见于多轮对话累积或单次请求过大。提供三级解决方案: 应急处理:输入"/new"指令清空会话历史,立即重置Token计数(90%问题可解决) 折中方案:保留历史对话前提下,通过精简当前输入、删除早期无关对话或拆分请求来压缩Token 专属处理:单次请求超限时,拆分长文本为2000字以内段落,或分批次上传降低分辨率图片 长期预防建议定期使用"/new"开启新会话,
YOLOv8 置信度阈值 (conf) 和 IoU 阈值 (iou) 详解:如何平衡漏检与误检?
摘要 本文深入探讨了YOLOv8目标检测模型中两个关键参数——置信度阈值(conf)和IoU阈值(iou)的核心作用。文章从目标检测的基础概念出发,解释了置信度分数反映模型预测可靠性,IoU衡量预测框重叠程度。重点剖析了非极大值抑制(NMS)机制如何通过这两个阈值进行预测框筛选:置信度阈值作为初筛门槛,IoU阈值决定重叠框的取舍。通过生动比喻和可视化图表,阐述了合理调节这两个参数能有效平衡误检与漏检问题,是优化YOLOv8模型实际表现的重要技巧。全文以实践为导向,帮助开发者掌握成为"调参大师&qu
Just a Hook(线段树)
题目链接: Just a Hook 大致题意 给定一个n, 对于区间[1, n]有如下操作: 选定l, r, 把[l, r]区间全部修改为数值c 最后输出[1, n]的区间和 解题思路 考察线段树的区间修改 + 根结点查询. 最后输出语句记得要复制样例的输出!!! 复制全!!! 我少复制了个’.’, debug了半天 TwT AC代码 #include <bits/stdc++.h> #define rep(i, n) for (int i = 1; i <= (n); ++i) usin
假人有限元模型
假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用
HDU 1696 Just a Hook 线段树
HDU 1696 Just a Hook 题目大意: 存在一串长度为n的序列,初始值全为1,给出q次操作,每次操作输入l、r、s,表示将区间 l 到 r 之间的值全部改为 s,其中1&lt;=s&lt;=3,序列长度1&lt;=n&lt;=100,000,操作次数0&lt;=q&lt;=100,000。要求输出q次操作之后序列的和。有多组输入样例。 大致思路: 因为是更改区间的值,所以会和区间上加...
Outlook Express 6 (OE6) for Win7/Win8/Win10
英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。
温度PID控制PLC程序
温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值
【线段树区间更新】hdu1698 Just a Hook
【线段树区间更新】hdu1698 Just a Hook 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 l
文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况
主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。
Just a Hook(线段树)
Just a Hook(线段树) Time limit:2000 ms Memory limit:32768 kB OS:Windows judge:https://vjudge.net/contest/295911#problem/E 描述 In the game of DotA, Pudge’s meat hook is actually the most horrible thing for...
线段树 Just a Hook
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 lengt
hdu 1698 Just A Hook 线段树的一道题
关于线段树以前也有过接触,不过忘了,重新回顾一下,线段树是用二叉树来实现的。 关于线段树的概念,这个blog写的很详细,大家可以看一下http://www.cnblogs.com/shuaiwhu/archive/2012/04/22/2464583.html hdu 1698 Just A Hook 这题题意是屠夫的钩子为n的长度,每段的材质都可以改变,一开始都是铜材质的,经过q次变化后求
线段树(成段更新)hdu 1698 Just a Hook
根据大神博客NotOnlySuccess的讲解,这个题目应该是属于线段树应用的第二阶段,也就是“成段更新”。大神博客已经有代码了,可能由于本题目不是很难所以没有过多的注释,如果是新手还是不容易看懂。所以这里就在啰嗦讲解一点吧。 题目:hdu 1698 Just a Hook 题目大意:dota中的屠夫(英雄)有一个钩子,钩子是连续的,现在假设钩子编号是从1到n,每个钩子有三种状态,分别对应的值
线段树(成段更新) HDU 1698 Just a Hook
题目传送门 1 /* 2 线段树-成段更新:第一题!只要更新区间,输出总长度就行了 3 虽然是超级裸题,但是用自己的风格写出来,还是很开心的:) 4 */ 5 #include <cstdio> 6 #include <algorithm> 7 #include <cmath> ...
HDU 1698 Just a Hook(线段树:区间set,区间查询)
HDU 1698 Just a Hook(线段树:区间set,区间查询) 分析:线段树区间set基本操作,详情看刘汝佳训练指南。 //HDU 1698 线段树 区间set 区间查询 #include #include #include using namespace std; #define lson i*2,l,m #define rson i*2+1,m+1,r const int MA
HDU-1698 Just a Hook(线段树模板,懒标记区间修改)
HDU-1698 Just a Hook /* * HDU-1698 Just a Hook * http://acm.hdu.edu.cn/showproblem.php?pid=1698 */ #include <iostream> #include <algorithm> #include <cstring> #include <vector> #include <queue> using namespace std; const
HDU 1698 Just a Hook 线段树
Just a Hook Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 28602 Accepted Submission(s): 14179 Problem Description In the game
Just a Hook(线段树,成段更新)
#include<bits/stdc++.h> using namespace std; const int N=1e5 +9; int T, n, m, x, y ,z; struct segtree{ int sum, tag, c; }tr[N<<2]; inline int read() { int ans=0; char last=' ',ch=getchar(); while(ch<'0'||ch>'9') last=ch,ch=ge
Just a Hook 【线段树】
题目链接:HDU-1698 [kuangbin带你飞]专题七 线段树 题目描述: 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...
【hdu】【线段树入门】Just a Hook
Problem DescriptionIn 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 le
6485




被折叠的 条评论
为什么被折叠?



