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;
}

 

springboot052基于Springboot+Vue旅游管理系统毕业源码案例设计 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值