链接: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. POJ - 3468 线段树区间修改,区间求和

    由于是区间求和,因此我们在更新某个节点的时候,需要往上更新节点信息,也就有了tree[root].val=tree[L(root)].val+tree[R(root)].val; 但是我们为了把懒标记 ...

  2. AtCoder Beginner Contest 122 D - We Like AGC (DP)

    D - We Like AGC Time Limit: 2 sec / Memory Limit: 1024 MB Score : 400400 points Problem Statement Yo ...

  3. siteServer创建网站中Mysql和SqlServer的区别

    mysql中使用本地数据库时使用:localhost sqlserver使用本地数据库时使用:(local)

  4. Django restful 规范

    一.REST Frame Work REST与技术无关,代表的是一种软件架构风格,REST是Representational State Transfer的简称,中文翻译为"表征状态转移&q ...

  5. Servlet 快速概览

    目录 生命周期 web.xml 获取表单数据(设置请求的编码格式) 返回响应内容(设置响应的编码格式) 结合前两点,总结基本模板 获取请求协议头部信息 设置响应头部信息 使用过滤器 在web.xml中 ...

  6. windows中在vs code终端使用bash

    vs code Visual Studio Code的缩写,很好用的一个编辑器. 终端 vs code的终端(命令行)在windows中,默认使用的是powershell,如下图所示: powersh ...

  7. 初次使用beego框架

    安装beego框架以及bee工具 go get -u github.com/astaxie/beego go get github.com/beego/bee 创建一个新项目 bee new weba ...

  8. react中如何使用动画效果

    在react中想要加入动画效果 需要引入 import {CSSTransitionGroup} from 'react-transition-group' //加入react 动画包 import ...

  9. [转帖]再次提醒Google Chrome用户应尽快升级浏览器到72.0.3626.121

    再次提醒Google Chrome用户应尽快升级浏览器到72.0.3626.121 转帖地址: https://www.cnbeta.com/articles/tech/825591.htm 国内离线 ...

  10. python学习笔记(5)-time库的使用

    import time 一.时间获取函数 time(), ctime(),gmtime() >>> import time >>> time.time() 1524 ...