zoukankan      html  css  js  c++  java
  • HDU6808 Go Running(未解决问题

    https://vjudge.net/contest/386568#problem/G

    Zhang3 is the class leader. Recently she's implementing a policy about long-distance running. This forces every student in her class to take a run.

    There is a main road in the school from west to east, which can be regarded as an infinite axis, and its positive direction is east. Positions on the road are represented with numbers. In order to complete the task, each student must run along the main road. Each student can decide the following things:

    - The time to start running.
    - The time to finish running.
    - The position to start running.
    - The direction of running, which is either west or east.

    Once these things are decided, the student will appear at the starting position on the road at the start time, then start running in the chosen direction at a speed of 1m/s1m/s. The student disappears at the finish time. Each student will only run once.

    Zhang3 knows that some students are not following her policy, so she set up some monitors. According to technical issues, the monitors can only report that there's at least one student at a certain place at a certain time. Finally Zhang3 received nn reports.

    Help Zhang3 determine the minimum possible number of students who have run.

    InputThe first line of the input gives the number of test cases, T(1T100)T(1≤T≤100). TT test cases follow.

    For each test case, the first line contains an integer n(1n105)n(1≤n≤105), the number of reports.

    Then nn lines follow, the ithith of which contains two integers ti,xi(1ti,xi109)ti,xi(1≤ti,xi≤109), representing that there's at least one student at position xi(m)xi(m) at time ti(s)ti(s).

    The sum of nn in all test cases doesn't exceed 5×1055×105.
    OutputFor each test case, print a line with an integer, representing the minimum number of students who have run.Sample Input

    2
    3
    1 1
    2 2
    3 1
    3
    1 1
    2 2
    3 3

    Sample Output

    2
    1

    分析:

    转换为二分图的最小点覆盖问题。

    将平面旋转45°,选择的直线变为水平或者竖直的直线。
    建图(二分图):

      对于旋转后的一个点(xi,yi),

      连接1条从左侧的点xi到右侧的点yi的边。

      目标转换为选择二分图的若干顶点。

    若选择了一个左侧的点a , 视作选择了直线x = a;

    若选择了一个右侧的点b, 视作选择了直线y= b。

    发现:对于每条边,都需要满足它的端点中
    存在至少一个被选择的点。

    二分图的最小点覆盖等于二分图的最大匹配。求出这张二分图的最大匹配。

  • 相关阅读:
    Python基础:内置函数
    Python基础:获取平台相关信息
    Python生成器-博文读后感
    IP地址、域名、域名解析系统相关
    Flask:初次使用Flask-SQLAlchemy读取SQLite3
    Flask:初次使用Blueprints
    Flask:使用Eclipse+PyDev插件编辑基于package的项目
    Flask:操作SQLite3(0.1)
    SQLite数据库初步
    Flask:redirect()函数
  • 原文地址:https://www.cnblogs.com/SutsuharaYuki/p/13429681.html
Copyright © 2011-2022 走看看