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题意是小的毒物圈会落在大的里面,问最安全的建筑。
圆心一定有一个可行域,是以圆点为圆心,R-r为半径的圆,然后就要看各个建筑被覆盖的概率是多大,也就是以建筑为圆心,r为半径的圆与前面提到的可行域圆的相交面积。
取前几个相交面积最大且相等的就是答案。
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
const double pi = acos(-1.0);
double R, r;
inline double sqr(double t)
{
return t * t;
}
struct point
{
double x, y;
void input() {
scanf("%lf %lf", &x, &y);
}
point(int a=0, int b=0):x(a),y(b) {}
double dis(const point&z) const {
return sqrt( sqr(x-z.x) + sqr(y-z.y) );
}
double dis1(const point&z) const {
return sqr(x-z.x) + sqr(y-z.y);
}
}p[107];
struct Circle
{
point o;
double r;
Circle () {}
Circle (point c, double r):o(c),r(r){}
int ket(const Circle&z) const {
if( o.dis1(z.o) <= sqr(z.r-r) ) return 1;
return 0;
}
double area() {
return pi * r * r;
}
double area(const Circle & c) const {
double d = o.dis(c.o);
double a = acos( (r*r+d*d-c.r*c.r)/(2*r*d) );
double b = acos( (c.r*c.r+d*d-r*r)/(2*c.r*d) );
a = sin(a), b = sin(b);
double s1 = pi * r * r * (a / 2 / pi);
double s2 = pi * c.r * c.r * (b / 2 / pi);
double s3 = r * d * 0.5 * a;
return s1 + s2 - s3;
}
}c[107];
int main()
{
int T;
scanf("%d", &T);
while(T --) {
int n;
point O(0,0);
scanf("%d", &n);
scanf("%lf %lf", &R, &r);
c[0] = Circle(O, R - r);
for(int i = 1;i <= n;i ++) p[i].input();
for(int i = 1;i <= n;i ++) c[i] = Circle(p[i], r);
double res = 0.0;
vector<pair<double, int> > v;
for(int i = 1;i <= n;i ++) {
if(c[0].ket(c[i]) == 1) {
v.push_back(mp(c[i].area(), i) );
} else {
v.push_back(mp(c[i].area(c[0]), i));
}
res = max(res, v.back().first);
}
vector<int> pos;
for(int i = 1;i <= n;i ++) {
if(v[i-1].first == res) {
pos.push_back(i);
}
}
n = pos.size();
printf("%d\n", n);
for(int i = 0;i < n;i ++) printf("%d%c",pos[i],i==n-1?'\n':' ');
}
return 0;
}