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谁大的问 ...
随机推荐
- Hibernate之Hibernate的下载与安装
Hibernate用法十分简单,当我们在Java项目中引入Hibernate框架之后,就能以面向对象的方式来操作关系数据库了. 下载: 登陆Hibernate官网,下载Hibernate压缩包,win ...
- KNN算法的代码实现
# -*- coding: utf-8 -*-"""Created on Wed Mar 7 09:17:17 2018 @author: admin"&quo ...
- Python扩展模块——调用WindowsAPI(pywin32的简单使用)
这块使用的比较少,只用到了模拟键盘按键, 调用鼠标比较费事,是通过像素坐标实现的,如果没有特殊需求或万不得已不建议使用 import win32con import win32api win32api ...
- mingw打dll ,lib包命令和调用
1,下面的命令行将这个代码编译成 dll. gcc mydll.c -shared -o mydll.dll -Wl,--out-implib,mydll.lib 其中 -shared 告诉gcc d ...
- Linux入门:增加用户,并赋予权限
一.增加用户 1.增加用户,并指定主目录 # useradd –d /usr/sam -m sam此命令创建了一个用户sam,其中-d和-m选项用来为登录名sam产生一个主目录/usr/sam(/us ...
- HTTP协议扫盲(八 )响应报文之 Transfer-Encoding=chunked方式
一.什么是chunked编码? 分块传输编码(Chunked transfer encoding)是只在HTTP协议1.1版本(HTTP/1.1)中提供的一种数据传送机制.以往HTTP的应答中数据是整 ...
- JavaScript中Array数组的方法
查找: indexOf.lastIndexOf 迭代:every.filter.forEach.map.somereduce.reduceRight 用法: /* 1 查找方法: * arr.inde ...
- Mybatis自动生成Xml文件,针对字段类型为text等会默认产生XXXXWithBlobs的方法问题
默认情况下产生的Mapper.xml里面存在: 需要修改generatorConfiguration.xml,里面的table加属性,如: <table domainObjectName=&qu ...
- 哪些异常是RuntimeException?Sql异常属于RuntimeException吗?Spring下SQL异常事务回滚
一,为什么框架中根本没有对Exception的一般子类进行回滚配置,异常发生时,事务都进行了回滚 ,说好的只会对RuntimeException(Unchecked 非受检异常)回滚呢? 此时,我们就 ...
- Spark:如何替换sc.parallelize(List(item1,item2)).collect().foreach(row=>{})为并行?
代码场景: 1)设定的几种数据场景,遍历所有场景:依次统计满足每种场景条件下的数据,并把统计结果存入hive: 2)已有代码如下: case class IndoorOTTCalibrateBuild ...