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 nnn 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 RRR will be spawned on the island. After some time, the safe area will shrink down towards a random circle with radius rrr (r≤Rr \le Rr≤R). 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.InputThere are multiple test cases. The first line of input contains an integer TTT, indicating the number of test cases. For each test case:The first line contains three integers nnn (1≤n≤1001 \le n \le 1001≤n≤100), RRR and rrr (1≤r≤R≤1041 \le r \le R \le 10^41≤r≤R≤104), indicating the number of buildings and the radius of two safe circles.The following nnn lines each contains 2 integers xix_ixi​ and yiy_iyi​ (−104≤xi,yi≤104-10^4 \le x_i, y_i \le 10^4−104≤xi​,yi​≤104), indicating the coordinate of the buildings. Here we assume that the center of the original safe circle is located at (0,0)(0, 0)(0,0), and all the buildings are inside the original circle.It’s guaranteed that the sum of nnn over all test cases will not exceed 5000.OutputFor each test case output two lines.The first line contains an integer mmm, indicating the number of buildings with the highest probability to become safe buildings.The second line contains mmm 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 Input2
3 10 5
3 4
3 5
3 6
3 10 4
-7 -6
4 5
5 4Sample Output1
1
2
2 3

记建筑物到原点的距离为$Dis$,那么当$Dis\in[|R-2r|]$时概率都是固定的且是最大的。因为这个范围内的点能被任意的小圆覆盖。否则,概率随距离的增大而减小。因此分情况讨论即可。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <unordered_set>
#include <algorithm>
using namespace std;
#define scanf scanf_s

string s;

int dis[101];

int getDis(const int& x, const int& y) {
return x * x + y * y;
}

int main() {
ios::sync_with_stdio(false);
int T;
cin >> T;
while (T--) {
int n, R, r;
cin >> n >> R >> r;
int MIN = 2000000000;
for (int i = 1; i <= n; ++i) {
int x, y;
cin >> x >> y;
dis[i] = getDis(x, y);
MIN = min(MIN, dis[i]);
}
vector<int>Ans;
int Dis = (R - 2 * r) * (R - 2 * r);
if (MIN <= Dis) {
for (int i = 1; i <= n; ++i) {
if (dis[i] <= Dis) {
Ans.push_back(i);
}
}
}
else {
for (int i = 1; i <= n; ++i) {
if (dis[i] == MIN) {
Ans.push_back(i);
}
}
}
cout << Ans.size() << endl;
for (int i = 0; i < Ans.size(); ++i) {
cout << Ans[i];
if (i == Ans.size() - 1) {
cout << endl;
}
else {
cout << ' ';
}
}
}

}