POJ3225.Help with Intervals

这个题就是对区间的各种操作,感觉这道题写的一点意思都没有,写到后面都不想写了,而且更神奇的是,自己的编译器连结果都输不出来,但是交上就过了,也是令人头大的操作,这题没意思,不要写了。我写到后面就写不下去了,直接去看了别人的代码。。。

代码:

 #include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<cctype>
using namespace std;
typedef long long ll;
const int maxn=;
const int inf=0x3f3f3f3f;
const double eps=1e-;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1 int col[maxn<<],Xor[maxn<<],hash[maxn<<]; void fxor(int rt)
{
if(col[rt]!=-)col[rt]^=;
else Xor[rt]^=;
}
void pushdown(int rt)
{
if(col[rt]!=-){
col[rt<<]=col[rt<<|]=col[rt];
Xor[rt<<]=Xor[rt<<|]=;
col[rt]=-;
}
if(Xor[rt]){
fxor(rt<<);
fxor(rt<<|);
Xor[rt]=;
}
}
void update(char op,int L,int R,int l,int r,int rt)
{
if(L<=l&&r<=R){
if(op=='U'){
col[rt]=;
Xor[rt]=;
}
else if(op=='D'){
col[rt]=;
Xor[rt]=;
}
else if(op=='C'||op=='S'){
fxor(rt);
}
return ;
} pushdown(rt);
int m=(l+r)>>;
if(L<=m)update(op,L,R,lson);
else if(op=='I'||op=='C'){
Xor[rt<<]=col[rt<<]=;
}
if(R> m)update(op,L,R,rson);
else if(op=='I'||op=='C'){
Xor[rt<<|]=col[rt<<|]=;
}
}
void query(int l,int r,int rt)
{
if(col[rt]==){
for(int i=l;i<=r;i++){
hash[i]=;
}
return ;
}
else if(col[rt]==)return ;
if(l==r) return ; pushdown(rt);
int m=(l+r)>>;
query(lson);
query(rson);
}
int main()
{
col[]=Xor[]=;
char op,l,r;
int a,b;
while(~scanf("%c %c%d,%d%c\n",&op,&l,&a,&b,&r)){
a<<=,b<<=;
if(l=='(')a++;
if(r==')')b--;
if(a>b){
if(op=='C'||op=='I'){
col[]=Xor[]=;
}
}
else
update(op,a,b,,maxn,);
}
query(,maxn,);
int flag=;
int s=-,e;
for(int i=;i<=maxn;i++){
if(hash[i]){
if(s==-)s=i;
e=i;
}
else{
if(s!=-){
if(flag)printf(" ");
flag=;
printf("%c%d,%d%c",s&?'(':'[',s>>,(e+)>>,e&?')':']');
s=-;
}
}
}
if(!flag)printf("empty set");
puts("");
return ;
}

5道题解完成,感觉后面再写题就应该是要用脑子来写了,水题水一下就可以了,就这样吧,下次再集齐5道再来写线段树可真有意思呢续集(3)。

滚了滚了。。。

最新文章

  1. Rafy 框架-发布网页版用户手册
  2. SQL Server修改数据库对象所有者(Owner)浅析
  3. mysql 获取一个表中缺失的最小编号
  4. JS范围
  5. 用Markdown优雅的渲染我们的网页
  6. zookeeper 应用场景概述
  7. javascipt中的DOM对象
  8. mysql新手入门随笔3
  9. 学习TensorFlow,concat连接两个(或多个)通道
  10. 获取真实ip三个方法
  11. mysql的多表查询join
  12. Bjarne Stroustrup announces C++ Core Guidelines
  13. spark sql加载avro
  14. JSP基本_JSPの構成要素、アクション、ディレクティブ
  15. 死磕nginx系列--使用nginx做cache服务
  16. 实操一下&lt;python cookbook&gt;第三版1
  17. 【TP5.0】model的操作方法
  18. Mac OS 10.12 - 如何能够像在Windows一样切换中英文输入法和大小写键?
  19. 【bzoj4804】欧拉心算 解题报告
  20. datagrid(&quot;getSelections&quot;)只获取一行

热门文章

  1. Hadoop学习笔记系列
  2. 《Cracking the Coding Interview》——第7章:数学和概率论——题目1
  3. 《Cracking the Coding Interview》——第5章:位操作——题目8
  4. USACO Section1.3 Mixing Milk 解题报告
  5. 解决ubuntu发热严重的问题
  6. 孤荷凌寒自学python第四十四天Python操作 数据库之准备工作
  7. java web登录界面 源代码
  8. 真的讨厌ClickOnce这东西
  9. [CF632E]Thief in a Shop
  10. BZOJ1951 [Sdoi2010]古代猪文 【费马小定理 + Lucas定理 + 中国剩余定理 + 逆元递推 + 扩展欧几里得】