hdu 1698
来源:互联网 发布:水泵选型软件 编辑:程序博客网 时间:2024/06/07 23:08
hdu 1689
线段树区间染色,听说用map可以水过去。
#include<cstdio>#include<cstdlib>#include<cstring>#include<iostream>#include<algorithm>const int MAXN = 1000005;int tree[MAXN<<2];int n , q;int tot;inline void fold_down(const int si){ if(tree[si] != false) tree[si<<1] = tree[(si<<1)|1] = tree[si]; tree[si] = false;}inline void update(const int &v,const int l,const int r,const int ll,const int rr,const int si){ if(l == ll && r == rr) { fold_down(si); tree[si] = v; } else { int mid = (ll + rr)>>1; fold_down(si); if(r <= mid) update(v,l,r,ll,mid,si<<1); else if(l > mid) update(v,l,r,mid+1,rr,(si<<1)|1); else { update(v,l,mid,ll,mid,(si<<1)); update(v,mid+1,r,mid+1,rr,(si<<1)|1); } }}inline void count(const int ll,const int rr,const int si){ if(ll == rr) { tot += tree[si]; } else { int mid = (ll + rr)>>1; fold_down(si); count(ll,mid,si<<1); count(mid+1,rr,(si<<1)|1); }}int main(){ int T , num=0;#ifndef ONLINE_JUDGE freopen("hdu1698.in","r",stdin); freopen("hdu1698.out","w",stdout);#endif scanf("%d",&T); while(T--) { ++ num; memset(tree,0,sizeof(tree)); scanf("%d",&n); tree[1] = 1; scanf("%d",&q); while(q--) { int a , b , c; scanf("%d%d%d",&a,&b,&c); update(c,a,b,1,n,1); } tot=0; count(1,n,1); printf("Case %d: The total value of the hook is %d.\n",num,tot); }#ifndef ONLINE_JUDGE fclose(stdin); fclose(stdout); #endif return 0;}
0 0
- hdu 1698
- hdu 1698
- hdu 1698
- hdu 1698
- HDU 1698
- HDU 1698
- hdu 1698
- hdu 1698
- hdu 1698
- hdu 1698
- hdu 1698
- hdu 1698
- hdu 1698
- hdu 1698
- hdu 1698
- hdu-1698
- hdu 1698
- HDU 1698
- windows-内存映射文件
- 机器学习
- Andriod:开发环境部署,第一个Andriod程序
- 欢迎使用CSDN-markdown编辑器
- assert函数
- hdu 1698
- poj 2509 简单模拟(烟屁换烟)
- 启动 Eclipse 弹 Failed to load the JNI shared library jvm.dll
- 玩转大数据系列之Apache Pig如何与Apache Solr集成(二)
- Java接口与抽象类研究
- treap启发式合并(BZOJ2809)||splay||左偏树
- c与c++中struct区别
- 1. jdbc一般事务步骤
- class demo