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