博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【HDU】1199 Color the Ball
阅读量:4467 次
发布时间:2019-06-08

本文共 2110 字,大约阅读时间需要 7 分钟。

1 #include
2 #include
3 #include
4 #define MAXN 2010 5 using namespace std; 6 struct Line 7 { 8 int left,right,color; 9 }; 10 Line p[MAXN]; 11 int x[MAXN<<2],tree[MAXN<<4]; 12 bool vis[MAXN<<2]; 13 inline void PushDown(int rt) 14 { 15 if(tree[rt]!=-1) 16 { 17 tree[rt<<1]=tree[rt<<1|1]=tree[rt]; 18 tree[rt]=-1; 19 } 20 } 21 void Build(int L,int R,int rt) 22 { 23 if(L==R) 24 tree[rt]=0; 25 else 26 { 27 int mid=(L+R)>>1; 28 tree[rt]=-1; 29 Build(L,mid,rt<<1); 30 Build(mid+1,R,rt<<1|1); 31 } 32 } 33 void Update(int st,int en,int val,int L,int R,int rt) 34 { 35 if(st<=L&&R<=en) 36 tree[rt]=val; 37 else 38 { 39 int mid=(L+R)>>1; 40 PushDown(rt); 41 if(mid>=st) 42 Update(st,en,val,L,mid,rt<<1); 43 if(en>mid) 44 Update(st,en,val,mid+1,R,rt<<1|1); 45 } 46 } 47 void Query(int L,int R,int rt) 48 { 49 if(tree[rt]==1) 50 { 51 for(int i=L;i<=R;i++) 52 vis[i]=true; 53 } 54 else if(tree[rt]==-1) 55 { 56 int mid=(L+R)>>1; 57 Query(L,mid,rt<<1); 58 Query(mid+1,R,rt<<1|1); 59 } 60 } 61 int main() 62 { 63 char ch; 64 int n,m,k,i,j,st,en; 65 while(~scanf("%d",&n)) 66 { 67 if(n==0) 68 { 69 puts("Oh, my god"); 70 continue; 71 } 72 for(k=i=0;i
p[i].right) 76 swap(p[i].left,p[i].right); 77 if(ch=='b') 78 p[i].color=0; 79 else 80 p[i].color=1; 81 x[k++]=p[i].left; 82 x[k++]=p[i].right; 83 } 84 sort(x,x+k); 85 k=unique(x,x+k)-x; 86 for(i=k-1;i>0;i--) 87 { 88 if(x[i]!=x[i-1]+1) 89 x[k++]=x[i-1]+1; 90 } 91 sort(x,x+k); 92 Build(0,k-1,1); 93 for(i=0;i

转载于:https://www.cnblogs.com/DrunBee/archive/2012/06/02/2532230.html

你可能感兴趣的文章
用 UIWebView 代替 UITextView,解决行间距问题
查看>>
学习秦九韶算法
查看>>
Mysql中use filesort的误区
查看>>
npm和Node.js简介
查看>>
Spring AOP无法拦截Controller的原因
查看>>
Windows双系统
查看>>
Microsoft Project项目管理工具
查看>>
软件设计师-算法
查看>>
小米手机安装Google框架
查看>>
honpeyhonepy
查看>>
netaddr网络地址工具python
查看>>
OSI7层模型和网络排错、网络安全
查看>>
hash文件-对文件进行数字签名
查看>>
TCP_Wrappers基础知识介绍
查看>>
Central Post Office (Shiraz University Local Contest 2011 ) 树状dp
查看>>
51Nod - 1031 骨牌覆盖
查看>>
回顾环信使用
查看>>
JavaScript--函数对象的属性caller与callee
查看>>
特殊字符大全
查看>>
SQL - SQL 连接 JOIN 例解。(左连接,右连接,全连接,内连接,交叉连接,自连接)[转]...
查看>>