UVA 1146 Now or later
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的更多相关文章
- uva 1146 Now or late (暴力2-SAT)
/* 裸地2-SAT问题 关键是模型转化 最小的最大 显然二分 关键是Judge的时候怎么判断 每个航班是早是晚直接影响判断 早晚只能选一个 如果我们定义bool变量xi表示 i航班是否早到 每个航班 ...
- UVa 706 & ZOJ 1146 LC-Display
题目大意:给你一个数字n和字体大小s,输出数字的液晶显示.直接模拟,代码如下: #include <stdio.h> void draw(int n,int s,int row) { in ...
- BZOJ 1146: [CTSC2008]网络管理Network [树上带修改主席树]
1146: [CTSC2008]网络管理Network Time Limit: 50 Sec Memory Limit: 162 MBSubmit: 3522 Solved: 1041[Submi ...
- 关于MySql的1146错误修正
在Mysql数据库中建立连接Mysql后建立了一个数据库名叫Mysql后删除了系统自动建立的数个表,导入.sql文件运行后,想要运行相关的SQL语句却发现一些未知错误为 Table 'mysql.pr ...
- 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 ...
- uva 1354 Mobile Computing ——yhx
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5
- UVA 10564 Paths through the Hourglass[DP 打印]
UVA - 10564 Paths through the Hourglass 题意: 要求从第一层走到最下面一层,只能往左下或右下走 问有多少条路径之和刚好等于S? 如果有的话,输出字典序最小的路径 ...
- UVA 11404 Palindromic Subsequence[DP LCS 打印]
UVA - 11404 Palindromic Subsequence 题意:一个字符串,删去0个或多个字符,输出字典序最小且最长的回文字符串 不要求路径区间DP都可以做 然而要字典序最小 倒过来求L ...
- UVA&&POJ离散概率与数学期望入门练习[4]
POJ3869 Headshot 题意:给出左轮手枪的子弹序列,打了一枪没子弹,要使下一枪也没子弹概率最大应该rotate还是shoot 条件概率,|00|/(|00|+|01|)和|0|/n谁大的问 ...
随机推荐
- find命令之(-atime,-ctime,-mtime)
关于find命令,以拙见总结如下: >>>定义: find命令用来在指定目录下查找文件. 任何位于参数之前的字符串都将被视为欲查找的目录名.如果使用该命令时,不设置任何参数,则fin ...
- BM V7000数据恢复成功案例;服务器数据恢复
IBM V7000存储是一款定位中端的存储设备,很多企业选择该服务器作为存储,最近北亚数据恢复中心接到一例V7000服务器数据恢复案例,下面将对本次数据恢复的过程和数据恢复方法进行归纳总结,希望对各位 ...
- JAVA_SE基础——40.super关键字
只要this关键字掌握了,super关键字不在话下,因为他们原理都差不多的.. this&super 什么是this,this是自身的一个对象,代表对象本身,可以理解为:指向对象本身的一个指针 ...
- python 关键字的操作
声明:本文章默认使用的是python 3.6.1 1.要想当个牛逼的程序员,就要精通各种hello world的写法,当然,我不牛逼,只能用python去写^..^! print("Hell ...
- Python内置函数(61)——eval
英文文档: eval(expression, globals=None, locals=None) The arguments are a string and optional globals an ...
- Mego开发文档 - 数据库建模
数据库建模 我们还提供了一些其他的特性,用于定制化数据库对应的数据结构. 表映射 框架默认会使用CLR类型名称做为实际数据库的表名,当两者不一致时可以使用该特性强制表名称. [Table(" ...
- docker实践
我的docker 学习笔记2 ps axf docker run -d cyf:sshd /usr/sbin -D docker ps docker-enter.sh 686 ps axf ...
- 日推20单词 Day02
1.distinguish v. 区别,辨别 2.tension n. 紧张,不安 3.sympathy n. 同情,慰问 4.admiration n. 羡慕 5.jealousy n. 嫉妒 6. ...
- I/O和管道
一:I/O设备 I/O(Input/Output),即输入/输出,通常指数据在内部存储器和外部存储器或其他周边设备之间的输入和输出. 标准输入(STDIN):0 默认接受来自键盘的输入 标准输出(ST ...
- Hive:把一段包含中文的sql脚本粘贴到beeline client运行中文乱码
背景: 在做项目过程中不可能hive表中都是非中文字段.在最近做的项目中就遇到需要在beeline界面上执行查询脚本,但脚本中包含中文,正常一个脚本用文本写好后,粘贴到beeline窗口运行时,发现中 ...