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 ( 2
n
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 ...
随机推荐
- ssh公钥免密码登录
1,生成公钥 ssh-keygen -t rsa 2,上传至服务器 将个人电脑的公钥添加到服务器 cat id_rsa.pub >> ~/.ssh/authorized_keys 3,本地 ...
- SQL Server 2008 表变量参数(表值参数)用法
表值参数是 SQL Server 2008 中的新参数类型.表值参数是使用用户定义的表类型来声明的.使用表值参数,可以不必创建临时表或许多参数,即可向 Transact-SQL 语句或例程(如存储过程 ...
- vnextcn
Flag 标题 通过 提交 AC% 难度 E1 编写Hello World网站 9 17 52% 1 E2 编写Hello World控制台程序 11 13 84% 1 E3 控制器基础练 ...
- 为什么学习Python
因为做iOS开发的,之前一直用OC,但是突然有一天苹果说出Swift,但是那时候的Swift真的是Bug多多,语法都不固定,所以只是大致看了看,而一年多之后,Swift已经发布2.0了,语言也相对稳定 ...
- [小技巧]让C#的空值处理变得更优雅
参考 http://www.codeproject.com/Articles/739772/Dynamically-Check-Nested-Values-for-IsNull-Values?msg= ...
- ASP.NET&AJAX&JSON - 动态读取数据
因为之前帮WM组做了一个delivery的dashboard,大概用了3周的时间,.net也忘了差不多了,ajax和highchart表也是现学的,蛮费劲!总算也搞出来了.发帖纪录一下. 1. 前台A ...
- 2.Modelsim打开时出现的Error
Modelsim之error “unable to check out a viewer license necessary for use of the modelsim graph.Vsim is ...
- C语言函数返回数组
#include "stdio.h"/*int* set(int a,int *c){ int *b; b=malloc(sizeof(int)*3); c[0]=a; c[1]= ...
- 按键精灵实现自动退出的MsgBox消息框
要实现自动倒计时退出的消息框,代码如下: Set wsh = CreateObject("WScript.Shell") wsh.popup "设置完毕,3秒后自动退出! ...
- Log4Net学习【二】
Log4Net结构详解 当我们在描述为系统做日志这个动作的时候,实际上描述了3个点:做日志,其实就是在规定,在什么地方 用什么日志记录器 以什么样的格式做日志.把三个最重要的点抽取出来,即什么地方,日 ...