ZOJ
来源:互联网 发布:吴梅村 红楼梦 知乎 编辑:程序博客网 时间:2024/06/03 17:22
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
23 10 53 43 53 63 10 4-7 -64 55 4
Sample Output
1122 3
题意:吃鸡游戏,求最大概率是安全房子的房子。
解题思路:简单题,稍作思考即可发现,越靠近中心点的房子,会有更高的概率成为安全房子。但有一个边界,那就是在(R-2r)内的房子都有相同的概率成为安全房子。所以简单的处理一下就好了。
#include<iostream>#include<deque>#include<memory.h>#include<stdio.h>#include<map>#include<string.h>#include<algorithm>#include<vector>#include<math.h>#include<stack>#include<queue>#include<set>using namespace std;typedef long long int ll;struct building{ double p; int index;}list[1000];bool cmp(building a,building b){ return a.p<b.p;}bool cmp2(building a,building b){ return a.index<b.index;}int main(){ int t; scanf("%d",&t); while(t--){ int n; double R,r; scanf("%d%lf%lf",&n,&R,&r); vector<building> ans; vector<building> others; double x,y; for(int i=1;i<=n;i++){ scanf("%lf%lf",&x,&y); list[i].index=i; if(x*x+y*y<=(R-2*r)*(R-2*r)){ ans.push_back(list[i]); } else{ list[i].p=x*x+y*y; others.push_back(list[i]); } } if(ans.empty()){ sort(others.begin(),others.end(),cmp); double last=others[0].p; for(int i=0;i<others.size();i++){ if(others[i].p==last) ans.push_back(others[i]); } sort(ans.begin(),ans.end(),cmp2); printf("%d\n",ans.size()); for(int i=0;i<ans.size()-1;i++) printf("%d ",ans[i].index); printf("%d\n",ans[ans.size()-1].index); } else{ printf("%d\n",ans.size()); for(int i=0;i<ans.size()-1;i++) printf("%d ",ans[i].index); printf("%d\n",ans[ans.size()-1].index); } } return 0;}
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- Oracle 自动备份和删除的整理(非原创)
- shell入门--第一个shell脚本
- 博文阅读:WILDML-----在深度学习与自然语言处理领域的Attention和Memory(2016年1月3日)
- gitbash https git credentials 小乌龟 TortoiseGit 配置备忘
- javascript的作用域。
- ZOJ
- js中全局变量与局部变量实例、闭包
- 我们过日子吧
- CentOS 7.X 安装 node.js和 cnmp vue
- tf. np. 两类函数的坑。。。
- 滚动条
- linux shell脚本中cd命令无效的解决方法
- 【Android基础】setTextColor(),setBackgroundColor的参数设置方式
- spring定时任务详解(@Scheduled注解)