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的圆内,原点任意但是新的圆最多和原来的圆相切。
这题很好,但是我没写出来,原因是自己不会做,别人给我讲玩后我才搞懂怎么求
思路:算某个点概率用这个点恰好被覆盖是圆的半径所围成的角度
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
pair<int,int> s[105];
bool cmp(pair<int,int> a,pair<int,int>b)
{
return a.first<b.first;
}
int main()
{
int t;cin>>t;
while(t--)
{
memset(s,0,sizeof(s));
int n,R,r;cin>>n>>R>>r;
int val=(R-2*r)*(R-2*r);
for(int i=0;i<n;i++)
{
int a, b;cin>>a>>b;
s[i].first=a*a+b*b; s[i].second=i+1;
}
sort(s,s+n,cmp);
vector<int>ans;
ans.push_back(s[0].second);
if(s[0].first<=val)
for(int i=1;i<n;i++){
if(s[i].first<=val)ans.push_back(s[i].second);
//cout<<"\\\\\n"<<endl;
}
else
for(int i=1;i<n;i++)if(s[i].first==s[0].first)ans.push_back(s[i].second);
cout<<ans.size()<<"\n";
sort(ans.begin(),ans.end());
for(int i=0;i<ans.size();i++)
cout<<ans[i]<<(i==ans.size()-1? '\n' : ' ');
}
return 0;
}