题目:http://acm.hdu.edu.cn/showproblem.php?pid=1698 题意:屠夫的钩子由等长的金属材料构成(1~N),每段的值为1,2或3,改变x~y之间的值,最后输出总和#include <stdio.h> const int maxn=100000; struct SegmentTree { int l, r, lazy, sum; }st[maxn<<2]; int t, n, q, x, y, z, cnt; void BuildTree(int v, int left, int right) { st[v].l=left, st[v].r=right, st[v].lazy=1; if (st[v].l==st[v].r) { st[v].sum=1; return; } int lc=v<<1; int rc=lc+1; int mid=(left+right)>>1; BuildTree(lc, left, mid); BuildTree(rc, mid+1, right); st[v].sum=st[lc].sum+st[rc].sum; } void Insert(int left, int right, int v, int w) { if (st[v].lazy==w) return; if (st[v].l==left&&st[v].r==right) { st[v].lazy=w; st[v].sum=(right-left+1)*w; return; } int lc=v<<1; int rc=lc+1; if (st[v].lazy!=-1) { st[lc].lazy=st[v].lazy, st[rc].lazy=st[v].lazy; st[lc].sum=(st[lc].r-st[lc].l+1)*st[lc].lazy; st[rc].sum=(st[rc].r-st[rc].l+1)*st[rc].lazy; st[v].lazy=-1; } int mid=(st[v].l+st[v].r)>>1; if (left>mid) Insert(left, right, rc, w); else if (right<=mid) Insert(left, right, lc, w); else { Insert(left, mid, lc, w); Insert(mid+1, right, rc, w); } st[v].sum=st[lc].sum+st[rc].sum; } int main() { //freopen("in.txt", "r", stdin); scanf("%d", &t); cnt=1; while (t--) { scanf("%d", &n); BuildTree(1, 1, n); scanf("%d", &q); for (int i=0; i<q; i++) { scanf("%d %d %d", &x, &y, &z); Insert(x, y, 1, z); } printf("Case %d: The total value of the hook is %d.\n", cnt++, st[1].sum); } }
相关推荐
OPC UA 协议详解
OPC UA(统一架构)是新一代工业自动化标准通信协议,替代传统OPC Classic,具有跨平台、高安全性、标准化等优势。基于TCP协议,支持全平台部署,采用面向对象架构组织数据,提供实时读写、事件订阅、历史数据访问等功能。作为工业4.0核心协议,适用于智能制造、数字孪生等场景,能实现多品牌设备统一接入。相比Modbus和MQTT,OPC UA协议更规范安全但复杂度较高,是大型工业集群互联的主流选择。
[kuangbin带你飞]专题七 线段树E - Just a Hook HDU - 1698
E - Just a Hook HDU - 1698 #include<bits/stdc++.h> using namespace std; const int M = 100000+100; int st[M<<2],lazy[M<<2]; void pushdown(int l,int r,int rt) { if(lazy[rt]) { ...
叶绿体基因组提交NCBI全流程避坑指南
叶绿体基因组作为环状细胞器DNA,其数据提交并非简单上传,而是需严格遵循INSDC标准的学术出版行为。其核心原理在于元数据完整性、拓扑结构语义一致性与分类学路径精确匹配;技术价值体现在保障序列可追溯、可复现、可互操作;典型应用场景涵盖植物系统发育、条形码开发及合成生物学底盘构建。实践中,FASTA头行格式、feature table嵌套规则、taxid绑定及BankIt静默校验等环节极易引发失败。本文聚焦NCBI|叶绿体基因组数据上传中的高频报错与隐性约束,提供面向生物信息工程师的实操级规范解析。
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
微信小程序音视频通话(for硬件)授权与设备注册实战指南
本文详细介绍了微信小程序音视频通话(for硬件)组件的开发实践,涵盖授权流程、设备注册与VoIP插件集成。重点解析了如何通过服务端获取snTicket实现用户授权,确保硬件设备与微信端的音视频通话安全可靠,适用于智能门禁、话机等物联网场景。
光模块的封装工艺有哪些?
COB封装传统的单路10Gb/s或25Gb/s速率的光模块采用SFP封装将电芯片和TO封装的光收发组件焊接到PCB板上组成光模块。但对于40G及以上速率的高速光模块,受激光器速率限制(多为25G),主要通过多通道并行实现,如40G由4×10G实现,而100G则由4×25G实现。蝶形封装:壳体通常为长方体,结构及实现功能通常比较复杂,可以内置制冷器、热沉、陶瓷基块、芯片、热敏电阻、背光监控,并且可以支持所有以上部件的键合引线。BOX封装属于蝶形封装的一种,用于多通道并行封装。
【线段树区间更新】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
桁架 拓扑优化 matlab程序_拓扑优化在结构轻量化及板壳加筋肋最优布置的应用...
1 拓扑优化简介材料的有效利用一直都是人类追求的目标,也是许多研究领域不变的话题,并伴随着结构优化理论和方法的产生而发展。结构优化设计通常分为三个层次:(1)拓扑优化:在一个确定的连续区域内寻求结构内部非实体区域位置和数量的最佳配置,寻求结构中的构件布局及节点联结方式最优化,使结构能在满足应力、位移等约束条件下,将外载荷传递到结构支撑位置,同时使结构的某种性态指标达到最优;(2)形状优化:指在保持...
HDU-1698-Just a Hook
HDU-1698-Just a Hook http://acm.hdu.edu.cn/showproblem.php?pid=1698 还是成段更新线段树 #include<stdio.h> #include<string.h> #include<stdlib.h> #define N 100005 struct cam { int x; int y;...
SAP MM | 采购的自动寻源:货源清单(ME01)与配额协议(MEQ1)的应用与 MRP 逻辑
SAP MM模块中,当物料有多个供应商时,MRP生成的采购申请常因"固定供应商"字段为空而无法自动发单。系统寻源优先级为:配额协议>货源清单>采购信息记录。解决方案包括:1)货源清单指定唯一固定供应商;2)配额协议按比例精准拆分;3)配额协议长期分配更推荐。手工创建采购申请时配额协议无效。建议优先使用货源清单Fix标识或配额分配功能,避免拆分导致的单据碎片化。
Sigrity System Explorer Transient Analysis模式进行瞬态仿真分析操作指导-单端信号-串联端接
Sigrity System Explorer Transient Analysis模式可以用于瞬态仿真分析,通过搭建简易拓扑用于前仿真分析通道的时域性能,下面搭建一个简易的单端拓扑并且进行串联端接,以下图为例,准备好发送接收端的IBIS模型, (se_example.ibs,本例发送接收端都使用相同的IBIS模型),以及传输线的S参数模型(W1_welement_se.sp)最上方的图形界面是传输线的模型,本例是一个上下都有参考平面的带状线,右侧的梯形是蚀刻角度,根据W1和W2以及铜厚来确定。
线段树(成段更新)hdu 1698 Just a Hook
根据大神博客NotOnlySuccess的讲解,这个题目应该是属于线段树应用的第二阶段,也就是“成段更新”。大神博客已经有代码了,可能由于本题目不是很难所以没有过多的注释,如果是新手还是不容易看懂。所以这里就在啰嗦讲解一点吧。 题目:hdu 1698 Just a Hook 题目大意:dota中的屠夫(英雄)有一个钩子,钩子是连续的,现在假设钩子编号是从1到n,每个钩子有三种状态,分别对应的值
ros入门(八)---TF坐标转换
TF(TransForm),就是坐标转换,包括了位置和姿态两个方面的变换。
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
RU DOS版、EFI版32bit/64bit BIOS常用工具
DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。
精雕软件(JDpaint) 5.5 绿色版
精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版
hdu1698Just a Hook
http://acm.hdu.edu.cn/showproblem.php?pid=1698 裸的线段树区间更新#include <iostream> #include <algorithm> #include <cstdio> #include <cstring>using namespace std; const int maxn=100005;struct Node { int su
文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况
主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。
hdu 1698 Just a Hook
http://acm.hdu.edu.cn/showproblem.php?pid=1698 Just a Hook Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 21917 Accepted Submission(s)
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): 25593 Accepted Submission(s): 12778 Problem Description In the game of D
线段树(成段更新) HDU 1698 Just a Hook
题目传送门 1 /* 2 线段树-成段更新:第一题!只要更新区间,输出总长度就行了 3 虽然是超级裸题,但是用自己的风格写出来,还是很开心的:) 4 */ 5 #include <cstdio> 6 #include <algorithm> 7 #include <cmath> ...
HDU1698-Just a Hook
http://acm.hdu.edu.cn/showproblem.php?pid=1698 #include<cstdio> #include<algorithm> #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 using namespace std; const int ma...
HDU1698 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...
【HDU 1698】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 ...
HDU1698Just 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 P...
723



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



