Safest Buildings ZOJ - 3993 (几何问题)

PUBG is a multiplayer online battle royale video game. In the game, up to one hundred players parachute onto an island and scavenge for weapons and equipment to kill others while avoiding getting killed themselves. BaoBao is a big fan of the game, but this time he is having some trouble selecting the safest building.

There are  buildings scattering on the island in the game, and we consider these buildings as points on a two-dimensional plane. At the beginning of each round, a circular safe area whose center is located at (0, 0) with radius  will be spawned on the island. After some time, the safe area will shrink down towards a random circle with radius  (). The whole new safe area is entirely contained in the original safe area (may be tangent to the original safe area), and the center of the new safe area is uniformly chosen within the original safe area.

The buildings covered by the new safe area is called the safe buildings. Given the radius of the safe areas and the positions of the buildings, BaoBao wants to find all the buildings with the largest probability to become safe buildings.

Input

There are multiple test cases. The first line of input contains an integer , indicating the number of test cases. For each test case:

The first line contains three integers  (),  and  (), indicating the number of buildings and the radius of two safe circles.

The following  lines each contains 2 integers  and  (), indicating the coordinate of the buildings. Here we assume that the center of the original safe circle is located at , and all the buildings are inside the original circle.

It's guaranteed that the sum of  over all test cases will not exceed 5000.

Output

For each test case output two lines.

The first line contains an integer , indicating the number of buildings with the highest probability to become safe buildings.

The second line contains  integers separated by a space in ascending order, indicating the indices of safest buildings.

Please, DO NOT output extra spaces at the end of each line.

Sample Input

2
3 10 5
3 4
3 5
3 6
3 10 4
-7 -6
4 5
5 4

Sample Output

1
1
2
2 3

 

题意:PUBG,,,一个大的安全区,然后给你第一次缩圈的半径,然后每个点为新圈圆心的概率相同,然后给你n个建筑物的坐标,问有几个建筑物是最大可能在新的安全区里的,依次输出来。


思路:当2*r>R时,中间的小圆里的建筑物最有可能且概率为1

 

当2*r<=R时,左边的小圆是新安全区的边界情况,与小圆相切的右边的圆里的建筑物的概率最大且为1

 

 

比较的时候,可以比较点到圆心的距离的平方是否在所述的两个圆里,

由于(2*r-R)*(2*r-R)==(R-2*r)*(R-2*r)

所以可以两种情况合起来写。

详见代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
using namespace std;
#define pb push_back
#define INF 0x3f3f3f3f
const int maxn=1e5+5;
struct node{int x, y;} pos[maxn];
vector<int> ans;
int main()
{
    int n,R,r,T;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d%d%d",&n,&R,&r);
        ans.clear();
        for(int i=1;i<=n;i++)
        {
            scanf("%d%d",&pos[i].x,&pos[i].y);
        }
        int minn=INF;
        for(int i=1;i<=n;i++)
        {
            //如果在符合条件的圆内,就取符合条件的圆的半径的平方,如果不在,就取此点到圆心的距离的平方
            int temp=max((R-2*r)*(R-2*r),pos[i].x*pos[i].x+pos[i].y*pos[i].y);
            minn=min(minn,temp);//使得最大值最小
        }
        for(int i=1;i<=n;i++)
        {
            int temp=max((R-2*r)*(R-2*r),pos[i].x*pos[i].x+pos[i].y*pos[i].y);
            if(minn==temp)//如果和最大值相等,就是概率最大的建筑
                ans.pb(i);
        }
        printf("%d\n",ans.size());
        for(int i=0;i<ans.size();i++)
            printf("%d%c",ans[i]," \n"[i==ans.size()-1]);
    }



    return 0;
}

 

内容概要:本文详细介绍了施耐德M580系列PLC的存储结构、系统硬件架构、上电写入程序及CPU冗余特性。在存储结构方面,涵盖拓扑寻址、Device DDT远程寻址以及寄存器寻址三种方式,详细解释了不同类型的寻址方法及其应用场景。系统硬件架构部分,阐述了最小系统的构建要素,包括CPU、机架和模块的选择与配置,并介绍了常见的系统拓扑结构,如简单的机架间拓扑和远程子站以太网菊花链等。上电写入程序环节,说明了通过USB和以太网两种接口进行程序下载的具体步骤,特别是针对初次下载时IP地址的设置方法。最后,CPU冗余部分重点描述了热备功能的实现机制,包括IP通讯地址配置和热备拓扑结构。 适合人群:从事工业自动化领域工作的技术人员,特别是对PLC编程及系统集成有一定了解的工程师。 使用场景及目标:①帮助工程师理解施耐德M580系列PLC的寻址机制,以便更好地进行模块配置和编程;②指导工程师完成最小系统的搭建,优化系统拓扑结构的设计;③提供详细的上电写入程序指南,确保程序下载顺利进行;④解释CPU冗余的实现方式,提高系统的稳定性和可靠性。 其他说明:文中还涉及一些特殊模块的功能介绍,如定时器事件和Modbus串口通讯模块,这些内容有助于用户深入了解M580系列PLC的高级应用。此外,附录部分提供了远程子站和热备冗余系统的实物图片,便于用户直观理解相关概念。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值