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

 #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. HDU 1034 Candy Sharing Game (模拟)

    题目链接 Problem Description A number of students sit in a circle facing their teacher in the center. Ea ...

  2. C++ STL标准入门

    C++:STL标准入门汇总 第一部分:(参考百度百科) 一.STL简介 STL(Standard Template Library,标准模板库)是惠普实验室开发的一系列软件的统称.它是由Alexand ...

  3. uboot makefile构建分析-续

    前言 这篇博文是 uboot makefile构建分析的续篇,继续分析uboot构建u-boot.bin的过程 构建u-boot.bin过程分析 makefile一开始,就是确定链接脚本.在构建ubo ...

  4. linux中的计算【转】

    shell中的赋值和操作默认都是字符串处理,在此记下shell中进行数学运算的几个特殊方法,以后用到的时候可以来看,呵呵 1.错误方法举例 a) var=1+1 echo $var 输出的结果是1+1 ...

  5. centos7-sar工具的安装过程及其简单应用

    一.sar工具安装 1.进入yum配置文件目录: cd /etc/yum.repos.d/ 2.vi CentOS-Base.repo命令创建文件CentOS-Base.repo 文件内容见网页:ht ...

  6. [转载]FFmpeg完美入门[4] - FFmpeg应用实例

    1 用FFserver从文件生成流媒体 一.安装ffmpeg 在ubuntu下,运行sudo apt-get ffmpeg 安装ffmpeg,在其他linux操作系统下,见ffmpeg的编译过程(编译 ...

  7. nginx配置--event模块

    在nginx的配置中,event模块可以进行以下配置: 设置网络连接的序列化. 在Nginx服务器的多进程下,有可能出现惊群(Thundering herd problem)问题,指的是当某一个时刻只 ...

  8. POJ 2513 Colored Sticks(Tire+欧拉回(通)路判断)

    题目链接:http://poj.org/problem?id=2513 题目大意:你有好多根棍子,这些棍子的两端分都别涂了一种颜色.请问你手中的这些棍子能否互相拼接,从而形成一条直线呢? 两根棍子只有 ...

  9. [前端随笔][JavaScript] 制作一个富文本编辑器

    写在前面 现在网上有很多现成的富文本编辑器,比如百度家的UEditor,kindeditor,niceditor等等,功能特别的多,API也很多,要去熟悉他的规则也很麻烦,所以想自己了解一下原理,做一 ...

  10. 洛谷P1008三连击 题解

    题目传送门 使用dfs搜索,搜索9个数字,注意回溯...最后判断是否符合条件,输出. #include<bits/stdc++.h> using namespace std; ],a[]; ...