这道题考察人的严谨,各种情况分类讨论。

 #include <cstdio>
#include <algorithm>
#include <map>
#define maxn 50010
#define maxq 17
#define P(i) (1<<(i))
#define yes 0
#define no 1
#define maybe 2
using namespace std; int n, q;
int year[maxn];
int st[maxn][maxq]; int ind( int y ) {
return (lower_bound( year+, year+n+, y ) - year);
}
void makest() {
for( int q=; q<maxq; q++ )
for( int i=; i<=(n-P(q)+); i++ )
st[i][q] = max( st[i][q-], st[i+P(q-)][q-] );
}
int fmax( int lf, int rg ) {
int len = rg-lf+;
if( len<= ) return -;
for( int q=maxq-; q>=; q-- )
if( len>P(q) ) {
return max( st[lf][q], st[rg-P(q)+][q] );
} else if( len==P(q) ) {
return st[lf][q];
}
return -;
}
int main() {
scanf( "%d", &n );
year[n+] = 0x7FFFFFFF;
for( int i=; i<=n; i++ )
scanf( "%d%d", year+i, &st[i][] );
makest();
sort( year+, year++n );
scanf( "%d", &q );
while( q-- ) {
int a, b, ia, ib;
scanf( "%d%d", &a, &b );
ia = ind(a), ib = ind(b);
if( year[ia]==a && year[ib]==b && b-a==ib-ia && st[ia][]>=st[ib][] && fmax(ia+,ib-)<st[ib][] ) {
printf( "true\n" );
continue;
}
if( year[ia]==a && year[ib]==b && b-a>ib-ia && st[ia][]>=st[ib][] && fmax(ia+(year[ia]==a),ib-)<st[ib][] ) {
printf( "maybe\n" );
continue;
}
if( ((year[ia]==a)^(year[ib]==b)) && fmax(ia+(year[ia]==a),ib-)< (year[ia]==a ? st[ia][] : st[ib][]) ) {
printf( "maybe\n" );
continue;
}
if( year[ia]!=a && year[ib]!=b ) {
printf( "maybe\n" );
continue;
}
printf( "false\n" );
}
}

bzoj 1067 分情况讨论的更多相关文章

  1. UESTC 1034 AC Milan VS Juventus 分情况讨论

    AC Milan VS Juventus Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Oth ...

  2. HNU 12833 Omar’s Bug(分情况讨论)

    题目链接:http://acm.hnu.cn/online/?action=problem&type=show&id=12833&courseid=268 解题报告:有个11个 ...

  3. Valid Number——分情况讨论最经典的题(没细看)——这题必须静下心来好好看看

    Validate if a given string is numeric. Some examples: "0" => true " 0.1 " =&g ...

  4. bzoj 1067: [SCOI2007]降雨量

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

  5. bzoj2756: [SCOI2012]奇怪的游戏(网络流+分情况)

    2756: [SCOI2012]奇怪的游戏 题目:传送门 题解: 发现做不出来的大难题一点一个网络流 %大佬 首先黑白染色(原来是套路...)染色之后就可以保证每次操作都一定会使黑白各一个各自的值加1 ...

  6. BZOJ 1067 降雨量(RMQ-ST+有毒的分类讨论)

    1067: [SCOI2007]降雨量 Time Limit: 1 Sec  Memory Limit: 162 MB Submit: 4399  Solved: 1182 [Submit][Stat ...

  7. HDU6444(子段和、分情况比较)

    要点 不难想到gcd一下然后枚举每个开头走一圈,并记录一下数值. 最终答案是分情况的:1.能走几圈走几圈然后加上最后剩余的最大子段和:2.也可能是最后一圈后面的拖后腿了,所以最后一圈没走完就停,即长度 ...

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

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

  9. CONTINUE...?模拟分情况

    CONTINUE...? DreamGrid has  classmates numbered from  to . Some of them are boys and the others are ...

随机推荐

  1. ubuntu16.04中启动anaconda图形化界面

    $ source ~/anaconda3/bin/activate root $ anaconda-navigator

  2. Sublime删除项目删不掉?

    最近用sublime进行项目的开发,感觉懵逼的像个小白菜~~ 今天遇到的问题可是一个超级白痴的问题,sublime的空白项目文件夹怎么都删不掉,我的傻逼操作是:选中文件--->Delete--- ...

  3. python3学习笔记.2.基础

    1.编码 默认编码是 utf-8 # -*- coding: utf-8 -*- 2.注释 单行注释  # 多行注释,用三个单引号或双引号 3.关键字 可在交互窗口查询. >>> i ...

  4. zedboard学习记录.2.PS+PL 流水灯与uart

    1.建立一个工程. 硬件设计 2.IP integrator -> create block desgin;Run Block Automation. 3.add IP -> AXI GP ...

  5. tf.reduce_sum()_tf.reduce_mean()_tf.reduce_max()

    根据官方文档: reduce_sum应该理解为压缩求和,用于降维 tf.reduce_sum(input_tensor,axis=None,keepdims=None,name=None,reduct ...

  6. 蓝色的oa模板html_综合信息服务管理平台OA模板——后台

    链接:http://pan.baidu.com/s/1qXGGOAK 密码:2otu

  7. Django框架<一>

    Django框架 Python的WEB框架有Django.Tornado.Flask 等多种,Django相较与其他WEB框架其优势为:大而全,框架本身集成了ORM.模型绑定.模板引擎.缓存.Sess ...

  8. sicily 1193. Up the Stairs

    Time Limit: 1sec    Memory Limit:32MB  Description John is moving to the penthouse of a tall sky-scr ...

  9. CentOS 7 中 Docker 的安装

    CentOS 7 中 Docker 的安装 Docker 软件包已经包括在默认的 CentOS-Extras 软件源里.因此想要安装 docker,只需要运行下面的 yum 命令: [root@loc ...

  10. java基础2 判断语句:if ... else 语句和 switch 语句

    一.if ... else 判断语句 1.if ... else 判断语句的格式 1.1.格式一 if(判断条件){ 执行不满足条件的语句 } 1.2.格式二 if(判断语句){ 满足条件的语句 }e ...