【题目链接】

点击打开链接

【算法】

线段树

此题细节很多,写程序时要细心!

【代码】

#include<bits/stdc++.h>
using namespace std;
#define MAXN 50010 struct Node
{
int l,r,mx;
} Tree[MAXN<<]; int i,n,l,r,posl,posr,q,mx;
int sum[MAXN],a[MAXN],y[MAXN]; template <typename T> inline void read(T &x)
{
int f = ; x = ;
char c = getchar();
for (; !isdigit(c); c = getchar()) { if (c == '-') f = -f; }
for (; isdigit(c); c = getchar()) x = (x << ) + (x << ) + c - '';
x *= f;
}
template <typename T> inline void write(T x)
{
if (x < )
{
putchar('-');
x = -x;
}
if (x > ) write(x/);
putchar(x%+'');
}
template <typename T> inline void writeln(T x)
{
write(x);
puts("");
}
inline void update(int index)
{
Tree[index].mx = max(Tree[index<<].mx,Tree[index<<|].mx);
}
inline void build(int index,int l,int r)
{
int mid;
Tree[index].l = l; Tree[index].r = r;
if (l == r)
{
Tree[index].mx = a[l];
return;
}
mid = (l + r) >> ;
build(index<<,l,mid);
build(index<<|,mid+,r);
update(index);
}
inline int query_max(int index,int l,int r)
{
int mid;
if (Tree[index].l == l && Tree[index].r == r) return Tree[index].mx;
mid = (Tree[index].l + Tree[index].r) >> ;
if (mid >= r) return query_max(index<<,l,r);
else if (mid + <= l) return query_max(index<<|,l,r);
else return max(query_max(index<<,l,mid),query_max(index<<|,mid+,r));
}
int main() { read(n);
for (i = ; i <= n; i++)
{
read(y[i]);
read(a[i]);
if (i == ) sum[i] = ;
else sum[i] = sum[i-] + (y[i] == y[i-] + );
}
build(,,n);
read(q);
while (q--)
{
read(l); read(r);
posl = lower_bound(y+,y+n+,l) - y;
posr = lower_bound(y+,y+n+,r) - y;
if (r < l)
{
puts("false");
continue;
}
if (posl == posr)
{
if (l == r) puts("true");
else puts("maybe");
continue;
}
if (posl + == posr)
{
if (y[posr] == r && y[posl] != l && a[posr] <= a[posl]) puts("false");
else if (y[posl] != l || y[posr] != r) puts("maybe");
else if (y[posl] != l && y[posr] != r) puts("maybe");
else
{
if (a[posr] > a[posl]) puts("false");
else
{
if (l + == r) puts("true");
else puts("maybe");
}
}
continue;
}
if (y[posl] == l && y[posr] == r)
{
if (sum[posr] - sum[posl] == r - l)
{
mx = query_max(,posl+,posr-);
if (a[posr] > mx && a[posr] <= a[posl]) puts("true");
else puts("false");
} else
{
mx = query_max(,posl+,posr-);
if (a[posr] <= mx || a[posr] > a[posl]) puts("false");
else puts("maybe");
}
continue;
}
if (y[posl] == l)
{
mx = query_max(,posl+,posr-);
if (mx >= a[posl]) puts("false");
else puts("maybe");
continue;
}
if (y[posr] == r)
{
mx = query_max(,posl,posr-);
if (mx >= a[posr]) puts("false");
else puts("maybe");
continue;
}
puts("maybe");
} return ; }

【SCOI 2007】 降雨量的更多相关文章

  1. 【BZOJ 1069】【SCOI 2007】最大土地面积 凸包+旋转卡壳

    因为凸壳上对踵点的单调性所以旋转卡壳线性绕一圈就可以啦啦啦--- 先求凸包,然后旋转卡壳记录$sum1$和$sum2$,最后统计答案就可以了 #include<cmath> #includ ...

  2. 图论(网络流):SCOI 2007 修车

    同一时刻有N位车主带着他们的爱车来到了汽车维修中心.维修中心共有M位技术人员,不同的技术人员对不同的车进行维修所用的时间是不同的.现在需要安排这M位技术人员所维修的车及顺序,使得顾客平均等待的时间最小 ...

  3. 解题:SCOI 2007 蜥蜴

    题面 拆点跑最大流 所有能跑出去的点连向汇点,容量为inf 原点连向所有初始有蜥蜴的点,容量为1 每根柱子拆成两个点“入口”和“出口”,入口向出口连容量为高度的边,出口向别的有高度的柱子的入口连容量为 ...

  4. [SCOI 2007] 修车

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=1070 [算法] 首先 , 我们发现 , 在倒数第i个修车会对答案产生i * k的贡献 ...

  5. [ SCOI 2007 ] Perm

    \(\\\) \(Description\) 给出只包括多个\(0\text~ 9\)的数字集,求有多少个本质不同的全排列,使得组成的数字能够整除\(M\). \(|S|\in [1,10]\),\( ...

  6. [SCOI 2007] 排列

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=1072 [算法] 状压DP [代码] #include<bits/stdc++. ...

  7. 【BZOJ1067】【POJ2637】降雨量

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

  8. C++之路进阶——codevs2439(降雨量)

    2439 降雨量 2007年省队选拔赛四川  时间限制: 1 s  空间限制: 64000 KB  题目等级 : 大师 Master       题目描述 Description 我们常常会说这样的话 ...

  9. BZOJ-1067 降雨量 线段树+分类讨论

    这道B题,刚的不行,各种碎点及其容易忽略,受不鸟了直接 1067: [SCOI2007]降雨量 Time Limit: 1 Sec Memory Limit: 162 MB Submit: 2859 ...

随机推荐

  1. PHP 反射API

    出处:http://blog.csdn.net/hguisu/article/details/7357421 PHP5添加了一项新的功能:Reflection.这个功能使得phper可以reverse ...

  2. django+uwsgi+nginx部署(非常详细)

    django+uwsgi+nginx部署 1.介绍: 在网上看了很多教程,但自己部署了很久都没有成功,这篇博文记录自己所踩过得坑. 2.环境: Ubuntu 16.04.1 LTS (GNU/Linu ...

  3. linux下的文档处理及tar命令

    1.使用cat命令进行纵向合并 使用‘>’是将左边的内容覆盖到右边 使用‘>>’是将左边的内容追加到右边文档中 还可使用‘>’将不同文件进行合并 2.管道符‘|’统计行数 使用 ...

  4. jQuery学习之------对标签属性的操作

    jQuery学习之------标签的属性 <a href=””>链接</a>此处的href就是该a标签带有的属性 在js中对标签的属性的操作方法有 1.1getAttribut ...

  5. 九度oj 题目1074:对称平方数

    题目1074:对称平方数 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:6422 解决:2912 题目描述: 打印所有不超过n(n<256)的,其平方具有对称性质的数. 如11*11 ...

  6. 56. spring boot中使用@Async实现异步调用【从零开始学Spring Boot】

    什么是"异步调用"? "异步调用"对应的是"同步调用",同步调用指程序按照定义顺序依次执行,每一行程序都必须等待上一行程序执行完成之后才能执 ...

  7. table 设置自动宽度后 td 的固定宽度 在 谷歌浏览器自动拉伸

    table   设置自动宽度后   td 的固定宽度  在 谷歌浏览器自动拉伸 解决方案 <table style="table-layout:fixed;">

  8. oracle exp direct 执行机制

    使用直接导出模式 direct=y exp 比传统模式导出快一倍 oracle提供2种模式导出表数据,传统模式CONVENTIONAL PATH和直接模式DIRECT PATH,有direct指定. ...

  9. [luoguP1044] 栈(数论?)

    传送门 卡特兰数 代码 #include <cstdio> int n; long long f[20]; int main() { int i; scanf("%d" ...

  10. Linux下汇编语言学习笔记56 ---

    这是17年暑假学习Linux汇编语言的笔记记录,参考书目为清华大学出版社 Jeff Duntemann著 梁晓辉译<汇编语言基于Linux环境>的书,喜欢看原版书的同学可以看<Ass ...