hdu1698 Just a Hook
来源:互联网 发布:淘宝新开店铺提取王 编辑:程序博客网 时间:2024/05/21 10:37
区间更新模板题
#include<iostream>#include<cstdio>#include<string>#include<cstring>#include<cmath>#include<algorithm>using namespace std;#define ll long long#define ull unsigned long long#define eps 1e-8#define inf 0x3f3f3f3f#define lson l, m, rt << 1#define rson m+1, r, rt << 1 | 1#define mnx 111111int sum[mnx<<2], col[mnx<<2];void pushup( int rt ){sum[rt] = sum[rt<<1] + sum[rt<<1|1];}void pushdown( int rt, int m ){if( col[rt] ){col[rt<<1] = col[rt<<1|1] = col[rt];sum[rt<<1] = ( m - (m >>1) ) * col[rt];sum[rt<<1|1] = (m >> 1) * col[rt];col[rt] = 0;}}void build( int l, int r, int rt ){if( l == r ){sum[rt] = 1;return ;}int m = ( l + r ) >> 1;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] = ( r - l + 1 ) * c;return ;}pushdown( rt, r - l + 1 );int m = ( l + r ) >> 1;if( L <= m ) update( L, R, c, lson );if( R > m ) update( L, R, c, rson );pushup( rt );}int main(){int cas, t = 1;scanf( "%d", &cas );while( cas-- ){memset( col, 0, sizeof(col) );int n, m, l, r, c;scanf( "%d%d", &n, &m );build( 1, n, 1 );for( int i = 0; i < m; i++ ){scanf( "%d%d%d", &l, &r, &c );update( l, r, c, 1, n, 1 );}printf( "Case %d: The total value of the hook is %d.\n", t, sum[1] );t++;}return 0;}
0 0
- 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
- 进制转换
- 串的模式匹配算法(KMP)
- 90. 啰唆的的日志会打断你的睡眠
- 设计模式目录
- 基于Spring MVC的Web应用开发(5) - Redirect
- hdu1698 Just a Hook
- adb shell dumpsys 命令
- 正则表达式的使用--去除字符串中空格
- Least Common Multiple
- 百思模组商城 - WWW.BESTMODULE.COM
- C++程序设计项目开发——银行自动提款机(一)
- Benchmark of Python WSGI Servers
- 跨函数使用内存
- blog