LA 3211
As you must have experienced, instead of landing immediately, an aircraft sometimes waits in a holding loop close to the runway. This holding mechanism is required by air traffic controllers to space apart aircraft as much as possible on the runway (while keeping delays low). It is formally defined as a ``holding pattern'' and is a predetermined maneuver designed to keep an aircraft within a specified airspace (see Figure 1 for an example).

Jim Tarjan, an air-traffic controller, has asked his brother Robert to help him to improve the behavior of the airport.
The TRACON area
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.
Example
Assume there are 10 aircraft in the TRACON area. Table 1 provides the corresponding early and late landing times (columns ``Early'' and ``Late'').
Aircraft | Early | Late | Solution |
A1 | 44 | 156 | Early |
A2 | 153 | 182 | Early |
A3 | 48 | 109 | Late |
A4 | 160 | 201 | Late |
A5 | 55 | 186 | Late |
A6 | 54 | 207 | Early |
A7 | 55 | 165 | Late |
A8 | 17 | 58 | Early |
A9 | 132 | 160 | Early |
A10 | 87 | 197 | Early |
The maximal security gap is 10 and the corresponding solution is reported in Table 1 (column ``Solution''). In this solution, the aircraft land in the following order: A8, A1, A6, A10, A3, A9, A2, A7, A5, A4. The security gap is realized by aircraft A1 and A6.
Input
The input file, that contains all the relevant data, contains several test cases
Each test case is described in the following way. The first line contains the number n of aircraft ( 2n
2000). This line is followed by n lines. Each of these lines contains two integers, which represent the early landing time and the late landing time of an aircraft. Note that all times t are such that 0
t
107.
Output
For each input case, your program has to write a line that conttains the maximal security gap between consecutive landings.
Sample Input
10
44 156
153 182
48 109
160 201
55 186
54 207
55 165
17 58
132 160
87 197
Sample Output
10
Note: The input file corresponds to Table 1.
Robert's Hints
- Optimization vs. Decision
- Robert advises you to work on the decision variant of the problem. It can then be stated as follows: Given an integer p, and an instance of the optimization problem, the question is to decide if there is a solution with security gap p or not. Note that, if you know how to solve the decision variant of an optimization problem, you can build a binary search algorithm to find the optimal solution.
- On decision
- Robert believes that the decision variant of the problem can be modeled as a very particular boolean satisfaction problem. Robert suggests to associate a boolean variable per aircraft stating whether the aircraft is early (variable takes value ``true'') or late (value ``false''). It should then be easy to see that for some aircraft to land at some time has consequences for the landing times of other aircraft. For instance in Table 1 and with a delay of 10, if aircraft A1 lands early, then aircraft A3has to land late. And of course, if aircraft A3 lands early, then aircraft A1 has to land late. That is, aircraft A1 and A3 cannot both land early and formula (A1
¬A3)
(A3
¬A1) must hold.
And now comes Robert's big insight: our problem has a solution, if and only if we have no contradiction. A contradiction being something like Ai ¬Ai.
二分答案走2 - sat
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <stack>
#include <vector>
#include <cmath> using namespace std; const int MAX_N = ;
int N,dfs_clock,scc_cnt;
int low[MAX_N],pre[MAX_N],cmp[MAX_N];
int E[MAX_N],L[MAX_N];
stack<int> S;
vector<int> G[MAX_N]; void dfs(int u) {
low[u] = pre[u] = ++dfs_clock;
S.push(u);
for(int i = ; i < G[u].size(); ++i) {
int v = G[u][i];
if(!pre[v]) {
dfs(v);
low[u] = min(low[u],low[v]);
} else if(!cmp[v]) {
low[u] = min(low[u],pre[v]);
}
} if(pre[u] == low[u]) {
++scc_cnt;
for(;;) {
int x = S.top(); S.pop();
cmp[x] = scc_cnt;
if(x == u) break;
}
}
} void scc() {
dfs_clock = scc_cnt = ;
memset(cmp,,sizeof(cmp));
memset(pre,,sizeof(pre)); for(int i = ; i <= * N; ++i){
if(!pre[i]) dfs(i);
}
} bool check(int x) {
for(int i = ; i <= * N; ++i) G[i].clear(); for(int i = ; i <= N; ++i) {
for(int j = ; j <= N; ++j) {
if(i == j) continue;
if(abs(E[i] - E[j]) < x) {
G[i].push_back(j + N);
G[j].push_back(i + N);
}
if(abs(E[i] - L[j]) < x) {
G[i].push_back(j);
G[j + N].push_back(i + N);
}
if(abs(L[i] - E[j]) < x) {
G[i + N].push_back(j + N);
G[j].push_back(i);
}
if(abs(L[i] - L[j]) < x) {
G[i + N].push_back(j);
G[j + N].push_back(i);
} }
} scc();
for(int i = ; i <= N; ++i) if(cmp[i] == cmp[i + N]) return false;
return true;
} void solve() {
int l = ,r = ;
for(int i = ; i <= N; ++i) {
r = max(r,E[i]);
r = max(r,L[i]);
} while(l < r) {
int mid = (l + r + ) / ;
if(check(mid)) l = mid;
else r = mid - ;
} printf("%d\n",l); } int main()
{
//freopen("sw.in","r",stdin);
while(~scanf("%d",&N)) {
for(int i = ; i <= N; ++i) {
scanf("%d%d",&E[i],&L[i]);
} solve();
}
//cout << "Hello world!" << endl;
return ;
}
LA 3211的更多相关文章
- LA 3211 飞机调度
题目链接:http://vjudge.net/contest/142615#problem/A 题意:n架飞机,每架可选择两个着落时间.安排一个着陆时间表,使得着陆间隔的最小值最大. 分析: 最小值最 ...
- LA 3211 飞机调度(2—SAT)
https://vjudge.net/problem/UVALive-3211 题意: 有n架飞机需要着陆,每架飞机都可以选择“早着陆”和“晚着陆”两种方式之一,且必须选择一种,第i架飞机的早着陆时间 ...
- 飞机调度 Now or Later? LA 3211 (2-SAT问题)
洛谷题目传送门 题目描述 有n架飞机需要着陆.每架飞机都可以选择“早着陆”和“晚着陆”两种方式之一,且必须选择一种.第i架飞机的早着陆时间为Ei,晚着陆时间为Li,不得在其他时间着陆.你的任务是为这些 ...
- 2-SAT 问题与解法小结
2-SAT 问题与解法小结 这个算法十分的奇妙qwq... 将一类判定问题转换为图论问题,然后就很容易解决了. 本文有一些地方摘录了一下赵爽<2-SAT解法浅析> (侵删) 一些概念: \ ...
- leggere la nostra recensione del primo e del secondo
La terra di mezzo in trail running sembra essere distorto leggermente massima di recente, e gli aggi ...
- Le lié à la légèreté semblait être et donc plus simple
Il est toutefois vraiment à partir www.runmasterfr.com/free-40-flyknit-2015-hommes-c-1_58_59.html de ...
- Mac Pro 使用 ll、la、l等ls的别名命令
在 Linux 下习惯使用 ll.la.l 等ls别名的童鞋到 mac os 可就郁闷了~~ 其实只要在用户目录下建立一个脚本“.bash_profile”, vim .bash_profile 并输 ...
- Linux中的动态库和静态库(.a/.la/.so/.o)
Linux中的动态库和静态库(.a/.la/.so/.o) Linux中的动态库和静态库(.a/.la/.so/.o) C/C++程序编译的过程 .o文件(目标文件) 创建atoi.o 使用atoi. ...
- BZOJ 3211 题解
3211: 花神游历各国 Time Limit: 5 Sec Memory Limit: 128 MBSubmit: 2549 Solved: 946[Submit][Status][Discus ...
随机推荐
- JavaWeb之Servlet: ServletConfig 与 ServletContext
ServletConfig对象 什么是ServletConfig对象 ServletConfig对象,叫Servlet配置对象.主要用于加载配置文件的初始化参数. 创建时机 ServletConfig ...
- HDU1009
题意:有n个房子,每个房子里都有老鼠喜欢吃的咖啡豆J[i],但是每个房子都有猫看守,老鼠现在手上有M的猫粮.可以用猫粮换咖啡豆,每只猫都有猫粮的要求F[i].老鼠得到的咖啡豆是J[i]*a% ...
- Express实现http和https服务
一.介绍Http与Https 概念 HTTP: 超文本传输协议(Hypertext transfer protocol) 是一种详细规定了浏览器和万维网服务器之间互相通信的规则,通过因特网传送万维网文 ...
- DB2物化表
DB2物化查询表(MQT)是DB2数据库中一类特殊的表 物化表和视图的区别 物化表是一个查询结果集,视图是一个SQL语句. 以下是一个简单例子(说明物化表) 1.创建表,插入测试数据 ----创建表 ...
- Redis 配置文件 redis.conf 项目详解
Redis.conf 配置文件详解 # [Redis](http://yijiebuyi.com/category/redis.html) 配置文件 # 当配置中需要配置内存大小时,可以使用 1k, ...
- CSS3中新出现的技术
CSS3中新出现的技术 CSS媒体查询 媒体查询 包含了一个媒体类型和至少一个使用如宽度.高度和颜色等媒体属性来限制样式表范围的表达式.CSS3加入的媒体查询使得无需修改内容便可以使样式应用于某些特定 ...
- spring 中的两个DaoSupport类的使用对比
可以利用NamedParameterJdbcDaoSupport 已经封装的NamedParameterJdbcTemplate方便的进行sql中参数的初始化工作. 相对于JdbcDaoSupport ...
- Android之通过向WebService服务器发送XML数据获取相关服务
原理图如下: 即客户端向WebService服务器通过HTTP协议发送XML数据(内部包含调用的一些方法和相关参数数据),然后WebService服务器给客户端返回一定的XML格式的数据 ...
- iOS8中如何将状态栏的字体颜色改为白色
网上的一些方法在我这行不通, 比如: UIApplication.sharedApplication().statusBarStyle = UIStatusBarStyle.LightContent ...
- Entity Framework 学习第二天
今天记录的内容不多,只是简单用一下Model first,新建项目,然后添加新建项,选择数据中的ado.net实体数据模型 这次我们选择空模型,然后右键,新增,实体 在这项demo中我打算建两个数据实 ...