zoukankan      html  css  js  c++  java
  • UVALive

    链接:

    https://vjudge.net/problem/UVALive-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).
    Figure 1: A simple Holding Pattern as described in a pilot text book.
    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
    Table 1: A 10 aircraft instance of the problem.
    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.

    思路:

    先考虑二分,每次重新建图。训练指南上的建图是传入两个或的关系,要满足这个或为真即可满足2-SAT。
    此题考虑两个飞机的降落时间不满足条件,加入图中。

    代码:

    //#include<bits/stdc++.h>
    #include<iostream>
    #include<string>
    #include<cstdio>
    #include<vector>
    #include<string.h>
    #include<cstring>
    #include<set>
    #include<queue>
    #include<algorithm>
    #include<math.h>
    #include<stdio.h>
    #include<map>
    #include<stack>
    using namespace std;
    typedef long long LL;
    typedef unsigned long long ULL;
    const int MOD = 20071027;
    const int MAXN = 2e3+10;
    int Next[4][2] = {-1, 0, 0, 1, 1, 0, 0, -1};
    
    vector<int> G[MAXN*2];
    stack<int> St;
    int dfn[MAXN*2], low[MAXN*2], sccnum[MAXN*2];
    int a[MAXN][2];
    int dfn_clock, scc_cnt;
    int n, m;
    
    void tarjan(int u)
    {
        dfn[u] = low[u] = ++dfn_clock;
        St.push(u);
        for (int i = 0;i < (int)G[u].size();i++)
        {
            int v = G[u][i];
            if (!dfn[v])
            {
                tarjan(v);
                low[u] = min(low[v], low[u]);
            }
            else if (!sccnum[v])
                low[u] = min(dfn[v], low[u]);
        }
        if (low[u] == dfn[u])
        {
            ++scc_cnt;
            while(true)
            {
                int x = St.top();
                St.pop();
                sccnum[x] = scc_cnt;
                if (x == u)
                    break;
            }
        }
    }
    
    bool solve()
    {
        memset(dfn, 0, sizeof(dfn));
        memset(low, 0, sizeof(low));
        memset(sccnum, 0, sizeof(sccnum));
        dfn_clock = scc_cnt = 0;
        for (int i = 0;i < 2*n;i++)
            if (!dfn[i]) tarjan(i);
        for (int i = 0;i < 2*n;i+=2)
            if (sccnum[i] == sccnum[i+1]) return false;
        return true;
    }
    
    void add_edge(int x, int xval, int y, int yval)
    {
        x = x*2+xval;
        y = y*2+yval;
        G[x^1].push_back(y);
        G[y^1].push_back(x);
    }
    
    bool check(int mid)
    {
        for (int i = 0;i < 2*n;i++)
            G[i].clear();
        for (int i = 0;i < n;i++) for (int p1 = 0;p1 < 2;p1++)
        {
            for (int j = i+1;j < n;j++) for (int p2 = 0;p2 < 2;p2++)
            {
                if (abs(a[i][p1]-a[j][p2]) < mid)
                    add_edge(i, p1^1, j, p2^1);
            }
        }
        return solve();
    }
    
    int main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0), cout.tie(0);
        while(cin >> n)
        {
            int l = 0, r = 0;
            for (int i = 0;i < n;i++)
            {
                cin >> a[i][0] >> a[i][1];
                r = max(r, max(a[i][0], a[i][1]));
            }
            int ans = 0;
            while(l <= r)
            {
                int mid = (l+r)/2;
                if (check(mid))
                {
                    ans = max(ans, mid);
                    l = mid+1;
                }
                else
                    r = mid-1;
            }
            cout << ans << endl;
        }
    
        return 0;
    }
    
    
  • 相关阅读:
    [再寄小读者之数学篇](2014-06-14 自然数集到自身的两个不可交换的双射)
    [再寄小读者之数学篇](2014-06-14 [四川师范大学 2014 年数学分析考研试题] 积分不等式)
    [家里蹲大学数学杂志]第294期微分方程与数学物理问题习题集
    这几天回家了
    SCI,EI,ISTP
    [家里蹲大学数学杂志]第049期2011年广州偏微分方程暑期班试题---随机PDE-可压NS-几何
    [家里蹲大学数学杂志]第048期普林斯顿高等研究所的疯子们
    [家里蹲大学数学杂志]第047期18 世纪法国数学界的3L
    [家里蹲大学数学杂志]第293期_偏微分方程基础教程
    [再寄小读者之数学篇](2014-06-03 华罗庚等式)
  • 原文地址:https://www.cnblogs.com/YDDDD/p/12141894.html
Copyright © 2011-2022 走看看