编程介的小学生 2017-06-20 08:27 采纳率: 20.5%
浏览 760
已采纳

Horizontal and Vertical Rays

Problem Description
There are H horizontal rays and V vertical rays. A horizontal ray is a straight line which originates at some point and extends infinitely far to the right (towards increasing X coordinates). A vertical ray is a straight line which originates at some point and extends infinitely far down (towards decreasing Y coordinates). A horizontal ray whose origin is (Xh,Yh) touches a vertical ray whose origin is (Xv,Yv) if Xh<=Xv and Yh<=Yv.
You must choose a subset S consisting of the minimum number of vertical rays such that each horizontal ray is touched by at least one vertical ray in S. It is guaranteed that it will always be possible to choose such a subset for the given test data.

Input
The first line of input contains an integer number T, representing the number of test cases to follow. The first line of each test case contains 2 integer numbers: H (1<=H<=100.000) and V (1<=V<=100.000). The next H lines contain 2 integers each: X and Y, representing the (X,Y) coordinates of the origins of the horizontal rays. The next V lines contain 2 integers each: X and Y, representing the (X,Y) coordinates of the origins of the vertical rays. All the X and Y coordinates in the input are in the range 0 ... 50.000.000.

Output
For each of the T test cases, in the order given in the input, print one line containing the minimum number of vertical rays chosen.

Sample Input
1
3 3
1 6
4 4
6 2
3 8
5 7
9 4

Sample Output
2

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-07-18 15:54
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。