The Terminal Radar Approach CONtrol (TRACON) controls aircraft approaching and departing

when they are between 5 and 50 miles of the airport. In this final scheduling process, air traffic

controllers make some aircraft wait before landing. Unfortunately this “waiting” process is complex

as aircraft follow predetermined routes and their speed cannot be changed. To reach some degree of

flexibility in the process, the basic delaying procedure is to make aircraft follow a holding pattern that

has been designed for the TRACON area. Such patterns generate a constant prescribed delay for an

aircraft (see Figure 1 for an example). Several holding patterns may exist in the same TRACON.

In the following, we assume that there is a single runway and that when an aircraft enters the

TRACON area, it is assigned an early landing time, a late landing time and a possible holding pattern.

The early landing time corresponds to the situation where the aircraft does not wait and lands as

soon as possible. The late landing time corresponds to the situation where the aircraft waits in the

prescribed holding pattern and then lands at that time. We assume that an aircraft enters at most

one holding pattern. Hence, the early and late landing times are the only two possible times for the

landing.

The security gap is the minimal elapsed time between consecutive landings. The objective is to

maximize the security gap. Robert believes that you can help.

题目大意:每架飞机可以选择早起飞和晚起飞,早起飞和晚起飞都有一个时间点,求一个安排方案,使得起飞时间的距离的最小值最大

对于最小值最大,显然二分答案,然后我们对于矛盾的建边,跑2-SAT即可

#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define RG register
#define il inline
#define iter iterator
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
using namespace std;
const int N=4005,M=16000005;
int gi(){
int str=0;char ch=getchar();
while(ch>'9' || ch<'0')ch=getchar();
while(ch>='0' && ch<='9')str=(str<<1)+(str<<3)+ch-48,ch=getchar();
return str;
}
int n,L[N],R[N],num=0,head[N],to[M],nxt[M];bool mark[N];
void init(int x,int y,bool tx,bool ty){
x=((x-1)<<1)+tx;y=((y-1)<<1)+ty;
nxt[++num]=head[x];to[num]=y;head[x]=num;
}
void Clear(){
memset(head,0,sizeof(head));num=0;
memset(mark,0,sizeof(mark));
}
int st[N],top=0;
bool dfs(int x){
if(mark[x])return true;
if(mark[x^1])return false;
mark[x]=true;st[++top]=x;
for(int i=head[x];i;i=nxt[i])
if(!dfs(to[i]))return false;
return true;
}
bool solve(){
int lim=(n<<1);
for(int i=0;i<lim;i+=2){
top=0;
if(!dfs(i)){
while(top)mark[st[top--]]=false;
if(!dfs(i^1))return false;
}
}
return true;
}
bool check(int mid){
Clear();
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(i==j)continue;
if(abs(L[i]-L[j])<mid)init(i,j,0,1);
if(abs(L[i]-R[j])<mid)init(i,j,0,0);
if(abs(R[i]-L[j])<mid)init(i,j,1,1);
if(abs(R[i]-R[j])<mid)init(i,j,1,0);
}
}
return solve();
}
void work()
{
for(int i=1;i<=n;i++){
L[i]=gi();R[i]=gi();
}
int l=0,r=1e7,mid,ans;
while(l<=r){
mid=(l+r)>>1;
if(check(mid))ans=mid,l=mid+1;
else r=mid-1;
}
printf("%d\n",ans);
} int main()
{
while(~scanf("%d",&n))work();
return 0;
}

UVA 1146 Now or later的更多相关文章

  1. uva 1146 Now or late (暴力2-SAT)

    /* 裸地2-SAT问题 关键是模型转化 最小的最大 显然二分 关键是Judge的时候怎么判断 每个航班是早是晚直接影响判断 早晚只能选一个 如果我们定义bool变量xi表示 i航班是否早到 每个航班 ...

  2. UVa 706 & ZOJ 1146 LC-Display

    题目大意:给你一个数字n和字体大小s,输出数字的液晶显示.直接模拟,代码如下: #include <stdio.h> void draw(int n,int s,int row) { in ...

  3. BZOJ 1146: [CTSC2008]网络管理Network [树上带修改主席树]

    1146: [CTSC2008]网络管理Network Time Limit: 50 Sec  Memory Limit: 162 MBSubmit: 3522  Solved: 1041[Submi ...

  4. 关于MySql的1146错误修正

    在Mysql数据库中建立连接Mysql后建立了一个数据库名叫Mysql后删除了系统自动建立的数个表,导入.sql文件运行后,想要运行相关的SQL语句却发现一些未知错误为 Table 'mysql.pr ...

  5. mysqldump:Couldn't execute 'show create table `tablename`': Table tablename' doesn't exist (1146)

    遇到了一个错误mysqldump: Couldn't execute 'show create table `CONCURRENCY_ERRORS`': Table INVOICE_OLD.CONCU ...

  6. uva 1354 Mobile Computing ——yhx

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5

  7. UVA 10564 Paths through the Hourglass[DP 打印]

    UVA - 10564 Paths through the Hourglass 题意: 要求从第一层走到最下面一层,只能往左下或右下走 问有多少条路径之和刚好等于S? 如果有的话,输出字典序最小的路径 ...

  8. UVA 11404 Palindromic Subsequence[DP LCS 打印]

    UVA - 11404 Palindromic Subsequence 题意:一个字符串,删去0个或多个字符,输出字典序最小且最长的回文字符串 不要求路径区间DP都可以做 然而要字典序最小 倒过来求L ...

  9. UVA&&POJ离散概率与数学期望入门练习[4]

    POJ3869 Headshot 题意:给出左轮手枪的子弹序列,打了一枪没子弹,要使下一枪也没子弹概率最大应该rotate还是shoot 条件概率,|00|/(|00|+|01|)和|0|/n谁大的问 ...

随机推荐

  1. 【Swift】Runtime动态性分析

    Swift是苹果2014年发布的编程开发语言,可与Objective-C共同运行于Mac OS和iOS平台,用于搭建基于苹果平台的应用程序.Swift已经开源,目前最新版本为2.2.我们知道Objec ...

  2. C++智能指针(auro_ptr...)

    写的很好,忍不住转了: 博文原址:http://blog.csdn.net/xt_xiaotian/article/details/5714477 一.简介 由于 C++ 语言没有自动内存回收机制,程 ...

  3. android 框架LoonAndroid,码农偷懒专用

    介绍 http://www.eoeandroid.com/thread-324764-1-1.html 架构培训视频: http://pan.baidu.com/s/1mgv8HTm 简介:下载 ht ...

  4. 深入浅出 SSL 管理配置实战

    我们生活在一个信息大爆炸的时代,几乎每天都在和互联网打交道,购物.网银转账.支付宝付款.搜索信息.查看邮件.观看视频.微信聊天.上网冲浪.阅读新闻等,无不时时刻刻在和网络打交道.那如何保护网络安全就相 ...

  5. MMA8451重力加速度计通过写内部校准寄存器进行校准

    |版权声明:本文为博主原创文章,未经博主允许不得转载. AN4069应用笔记中提到MMA8451的三个轴重力校准有两种方法, 第一种方法是简易校准,将贴有MMA8451的设备整体,Z轴正面朝上放在校准 ...

  6. api-gateway实践(15)API网关的待改进点 20171207

    一.API网关能力 API网关负责服务请求路由.组合及协议转换.客户端的所有请求都首先经过API网关,然后由它将请求路由到合适的微服务.API网关的客户端通过统一的网关接入微服务,在网关层处理所有的非 ...

  7. hadoop2.6.0实践:A03 例子验证

    [hadoop@LexiaofeiN1 ~]$ hdfs dfs -ls /output/grep[hadoop@LexiaofeiN1 ~]$ hdfs dfs -rm -R /output/gre ...

  8. maven常见问题处理(3-2)maven打包时跳过测试的几个方法

    运行mvn install时跳过Test方法一:<project> [...] <build> <plugins> <plugin> <group ...

  9. java子类重写父类的要点

    子类不能重写父类的静态方法,私有方法.即使你看到子类中存在貌似是重写的父类的静态方法或者私有方法,编译是没有问题的,但那其实是你重新又定义的方法,不是重写.具体有关重写父类方法的规则如下:重写规则之一 ...

  10. CentOS7 安装eclipse

    1. 首先将eclipse的压缩包文件解压到/opt目录下,要使用root权限.执行如下解压命令:tar -zxvf eclipse-jee-oxygen-1a-linux-gtk-x86_64.ta ...