链接:https://www.lydsy.com/JudgeOnline/problem.php?id=1067

思路: 毒瘤题,写的自闭,改了一晚上,注意要理清题目的逻辑 x小于等于y,x,y之间的数严格小于x,不能等于;

分类讨论懒得写的,很简单的分类讨论。

实现代码:

#include<bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define mid int m = (l + r) >> 1
const int M = 1e5+;
const int inf = 0x3f3f3f3f;
int vis[M];
int num[M<<],sum[M<<],x1[M],x2[M],yy[M],y2[M],cnt,a[M<<];
void pushup(int rt){
sum[rt] = max(sum[rt<<],sum[rt<<|]);
num[rt] = num[rt<<] + num[rt<<|];
} void update(int p,int c,int l,int r,int rt){
if(l == r){
sum[rt] = c;
num[rt] = ;
return ;
}
mid;
if(p <= m) update(p,c,lson);
else update(p,c,rson);
pushup(rt);
} int query(int L,int R,int l,int r,int rt){
if(L <= l&&R >= r){
return sum[rt];
}
mid;
int ret = -inf;
if(L <= m) ret = max(ret,query(L,R,lson));
if(R > m) ret = max(ret,query(L,R,rson));
return ret;
} int ask(int L,int R,int l,int r,int rt){
if(L <= l&&R >= r){
return num[rt];
}
mid;
int ret = ;
if(L <= m) ret += ask(L,R,lson);
if(R > m) ret += ask(L,R,rson);
return ret;
} int main()
{
int n,x,y,m;
scanf("%d",&n);
int cnt = ;
for(int i = ;i <= n;i ++){
scanf("%d%d",&x1[i],&yy[i]);
a[++cnt] = x1[i];
}
scanf("%d",&m);
for(int i = ;i <= m;i ++){
scanf("%d%d",&x2[i],&y2[i]);
a[++cnt] = x2[i];
a[++cnt] = y2[i];
}
sort(a+,a++cnt);
int nn = unique(a+,a++cnt)-(a+);
for(int i = ;i <= n;i ++){
x = lower_bound(a+,a+nn+,x1[i]) - a;
vis[x] = yy[i];
update(x,yy[i],,nn,);
}
for(int i = ;i <= m;i ++){
x = lower_bound(a+,a+nn+,x2[i]) - a;
y = lower_bound(a+,a+nn+,y2[i]) - a;
if(x > y){
printf("false\n");
continue;
}
if(!vis[x]&&!vis[y]) printf("maybe\n");
else if(vis[x]&&vis[y]){
int cnt = query(x+,y-,,nn,);
int flag = ask(x,y,,nn,);
if(cnt<vis[y]&&vis[y]<=vis[x]){
if(flag == y2[i]-x2[i]+) printf("true\n");
else printf("maybe\n");
}
else printf("false\n");
}
else if(!vis[x]&&vis[y]){
int cnt = query(x,y-,,nn,);
if(cnt >= vis[y]) printf("false\n");
else printf("maybe\n");
}
else{
int cnt = query(x+,y,,nn,);
if(cnt >= vis[x]) printf("false\n");
else printf("maybe\n");
}
}
return ;
}

bzoj 1067: [SCOI2007]降雨量 (离散化+线段树)的更多相关文章

  1. 1067. [SCOI2007]降雨量【线段树】

    Description 我们常常会说这样的话:“X年是自Y年以来降雨量最多的”.它的含义是X年的降雨量不超过Y年,且对于任意 Y<Z<X,Z年的降雨量严格小于X年.例如2002,2003, ...

  2. bzoj 1067: [SCOI2007]降雨量

    题目链接: bzoj 1067: [SCOI2007]降雨量 题解: 很简单的一道题,但代码里有许多细节需要注意,切容易出错,调了三个小时OTZ 做一个st表维护区间最大值就 在获得年份在序列中的po ...

  3. bzoj 1067: [SCOI2007]降雨量 模擬

    1067: [SCOI2007]降雨量 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 2010  Solved: 503[Submit][Status] ...

  4. 洛谷 2471 BZOJ 1067 [SCOI2007]降雨量

    [题解] 用线段树维护区间最大值(因为没有修改,St表也可以),然后由于x,y可能是降雨量未知的年份,需要进行分类讨论. #include<cstdio> #include<algo ...

  5. bzoj1067——SCOI2007降雨量(线段树,细节题)

    题目描述 我们常常会说这样的话:"X年是自Y年以来降雨量最多的".它的含义是X年的降雨量不超过Y年,且对于任意\(Y<Z<X\),Z年的降雨量严格小于X年.例如2002 ...

  6. 1067: [SCOI2007]降雨量

    1067: [SCOI2007]降雨量 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 2148  Solved: 554[Submit][Status] ...

  7. 南阳理工 题目9:posters(离散化+线段树)

    posters 时间限制:1000 ms  |  内存限制:65535 KB 难度:6   描述 The citizens of Bytetown, AB, could not stand that ...

  8. SGU 180 Inversions(离散化 + 线段树求逆序对)

    题目链接:http://acm.sgu.ru/problem.php?contest=0&problem=180 解题报告:一个裸的求逆序对的题,离散化+线段树,也可以用离散化+树状数组.因为 ...

  9. 【POJ】2528 Mayor's posters ——离散化+线段树

    Mayor's posters Time Limit: 1000MS    Memory Limit: 65536K   Description The citizens of Bytetown, A ...

随机推荐

  1. Python-初识算法-51

    # 什么叫算法# 计算的方法 : 人脑复杂 计算机简单 # 99 * 13 = 1287 = 13*100 - 13# 查找 : 找数据# 排序 :# 最短路径 # 我们学习的算法 都是过去时# 了解 ...

  2. H5 31-CSS元素显示模式转换

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. PS制作动感酷炫水人街舞照

    一.打开原图素材,用钢笔工具把人物从图中扣取出来,新建一个812 * 1024像素的文档,把抠出的人物拖进来,过程如下图. 二.用你习惯的修图工具把人物的手.脸部.腰部.袜子通通修掉.再补回衣服在透视 ...

  4. springboot在yml中配置控制台sql打印方法小结

    方法一: logging: level: debug level.io.renren: debug path: logs/ file: admin.log   方法二 logging:    leve ...

  5. iOS开发——无网占位图的实现

    https://www.jianshu.com/p/d537393fe247 https://github.com/wyzxc/CQPlaceholderViewhttps://github.com/ ...

  6. 斐波那契数列yield表示

    def fib(num): n=0 a,b=0,1 while n<num: print(b) yield a,b=b,a+b n=n+1a=fib(30)next(a)next(a)  

  7. Java 学习使用常见的开源连接池

    目录 连接池介绍 自定义连接池 JDBC Tomcat Pool DBCP(DataBase Connection Pool) 使用配置文件来设置DBCP C3P0 Druid 连接池介绍 在说连接池 ...

  8. MySQL :: Fatal error: Can&#039;t change to run as user &#039;mysql&#039;. Please check that the user exists!

    Fatal error: Can't change to run as user 'mysql'. Please check that the user exists! MySQL :: Fatal ...

  9. react组件传值传方法

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  10. java中的标记接口(标签接口)

    Java中的标记接口(Marker Interface),又称标签接口(Tag Interface),具体是不包含任何方法的接口.在Java中很容易找到标记接口的例子,比如JDK中的Serialzab ...