[HDU1698]Just a Hook
来源:互联网 发布:g92内锥度螺纹编程实例 编辑:程序博客网 时间:2024/04/30 15:19
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1698
#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<cmath>#include<map>#include<set>#include<vector>#include<utility>using namespace std;#define lson l , mid , rt << 1#define rson mid + 1 , r , rt << 1 | 1const int maxn = 120000;int col[maxn << 2], sum[maxn << 2];void PushUp(int rt){ sum[rt] = sum[rt << 1] + sum[rt << 1 | 1];}void build(int l, int r, int rt){ col[rt] = 0; sum[rt] = 1; if (l == r) return; int mid = (l + r) >> 1; build(lson); build(rson); PushUp(rt);}void PushDown(int rt, int len){ if (col[rt]) { col[rt << 1] = col[rt << 1 | 1] = col[rt]; sum[rt << 1] = (len - (len >> 1)) * col[rt]; sum[rt << 1 | 1] = (len >> 1) * col[rt]; col[rt] = 0; }}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 + 1); return; } PushDown(rt, r - l + 1); int mid = (l + r) >> 1; if (L <= mid) update(L, R, c, lson); if (R > mid) update(L, R, c, rson); PushUp(rt);}int main(){ int T; cin >> T; for (int kase = 1; kase <= T; kase++) { int len, Q; scanf("%d%d", &len, &Q); build(1, len, 1); while (Q--) { int a, b, c; scanf("%d%d%d", &a, &b, &c); update(a, b, c, 1, len, 1); } printf("Case %d: The total value of the hook is %d.\n", kase, sum[1]); }}
- hdu1698 Just a Hook
- hdu1698 Just a Hook
- [HDU1698]Just a Hook
- hdu1698 Just a Hook
- hdu1698 Just a Hook
- HDU1698 Just a Hook
- hdu1698 Just a Hook
- HDU1698 Just a Hook
- hdu1698-Just a Hook
- hdu1698 Just a Hook
- Just a Hook hdu1698
- hdu1698 Just a Hook
- hdu1698 Just a Hook
- HDU1698 Just a Hook
- HDU1698 Just a Hook
- HDU1698 Just a Hook
- HDU1698-Just a Hook
- HDU1698 Just a Hook
- 1.虚拟机毁坏Mbr,启动拯救模式的具体过程。
- UVA532
- 项目管理
- C# ToString常用技巧总结
- 【Java学习笔记】基础知识学习1【基本输出,数据类型,基础运算符号】
- [HDU1698]Just a Hook
- NoSuchMethodException: $Proxy 的解决方法
- JSValidation框架的使用整理总结
- 选择排序法 弄不懂
- EditPlus配置C环境
- hdu2682之最小生成树
- I/O端口和I/O内存
- 阻塞队列
- sleep和wait的区别