首页 > 其他分享 >FZU 2144 Shooting Game (贪心区域划分)

FZU 2144 Shooting Game (贪心区域划分)

时间:2022-10-18 14:03:37浏览次数:40  
标签:shoot 1.0 int brother FZU Game 2144 mosquito Fat

Problem 2144 Shooting Game
Accept: 370 Submit: 1902
Time Limit: 1000 mSec Memory Limit : 32768 KB

Problem Description

Fat brother and Maze are playing a kind of special (hentai) game in the playground. (Maybe it’s the OOXX game which decrypted in the last problem, who knows.) But as they don’t like using repellent while playing this kind of special (hentai) game, they really suffer a lot from the mosquito. So they decide to use antiaircraft gun to shoot the mosquito. You can assume that the playground is a kind of three-dimensional space and there are N mosquitoes in the playground. Each of them is a kind of point in the space which is doing the uniform linear motion. (匀速直线运动) Fat brother is standing at (0, 0, 0) and once he shoot, the mosquito who’s distance from Fat brother is no large than R will be shot down. You can assume that the area which Fat brother shoot is a kind of a sphere with radio R and the mosquito inside this sphere will be shot down. As Fat brother hate these mosquito very much, he wants to shoot as much mosquito as he can. But as we all know, it’s tired for a man to shoot even if he is really enjoying this. So in addition to that, Fat brother wants to shoot as less time as he can.

You can (have to) assume that Fat brother is strong enough and he don’t need to rest after shooting which means that can shoot at ANY TIME.

Input

The first line of the date is an integer T, which is the number of the text cases.

Then T cases follow, each case starts with two integers N and R which describe above.

Then N lines follow, the ith line contains six integers ax, ay, az, dx, dy, dz. It means that at time 0, the ith mosquito is at (ax, ay, az) and it’s moving direction is (dx, dy, dz) which means that after time t this mosquito will be at (ax+dx*t, ay+dy*t, ax+dz*t). You can assume that dx*dx + dy*dy+ dz*dz > 0.

1 <= T <= 50, 1 <= N <= 100000, 1 <= R <= 1000000

-1000000 <= ax, ay, az <= 1000000

-100 <= dx, dy, dz <= 100

The range of each coordinate is [-10086, 10086]

Output

For each case, output the case number first, then output two numbers A and B.

A is the number of mosquito Fat brother can shoot down.

B is the number of times Fat brother need to shoot.

Sample Input

6
2 1
2 0 0 -1 0 0
-2 0 0 1 0 0
2 1
4 0 0 -1 0 0
-2 0 0 1 0 0
2 1
4 0 0 -1 0 0
1 0 0 1 0 0
2 1
1 1 1 1 1 1
-1 -1 -1 -1 -1 -1
1 1
0 0 0 1 0 0
3 1
-1 0 0 1 0 0
-2 0 0 1 0 0
4 0 0 -1 0 0
Sample Output

Case 1: 2 1
Case 2: 2 1
Case 3: 2 2
Case 4: 0 0
Case 5: 1 1
Case 6: 3 2

可以根据出去的时间对蚊子进行排序,然后统计后面有多少蚊子进去的时间是小于这个蚊子的出去时间,这些蚊子可以同时杀死。

#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <algorithm>
#include <math.h>

using namespace std;
#define MAX 100000
int t;
int n,r;
struct Node
{
double leftime;
double getime;
}a[MAX+5];
int cmp(Node a,Node b)
{
if(a.leftime==b.leftime)
return a.getime<b.getime;
return a.leftime<b.leftime;
}
int ans;
int res;
int tag[MAX+5];
int main()
{
int x1,y1,z1,x2,y2,z2;
scanf("%d",&t);
int cas=0;
while(t--)
{
ans=0;
res=0;
scanf("%d%d",&n,&r);
int cnt=0;
for(int i=1;i<=n;i++)
{
scanf("%d%d%d%d%d%d",&x1,&y1,&z1,&x2,&y2,&z2);
double a1=(x2*1.0)*(x2*1.0)+(y2*1.0)*(y2*1.0)+(z2*1.0)*(z2*1.0);
double b=2*(x1*1.0)*(x2*1.0)+2*(y1*1.0)*(y2*1.0)+2*(z1*1.0)*(z2*1.0);
double c=(x1*1.0)*(x1*1.0)+(y1*1.0)*(y1*1.0)+(z1*1.0)*(z1*1.0)-(r*1.0)*(r*1.0);
double d=b*b-4*a1*c;
if(d<0) continue;
double xx=(-b+sqrt(d))/(2*a1);
double yy=(-b-sqrt(d))/(2*a1);
if(xx<0&&yy<0) continue;
a[cnt].getime=min(xx,yy);
if(a[cnt].getime<0) a[cnt].getime=0;;
a[cnt++].leftime=max(xx,yy);
}
sort(a,a+cnt,cmp);
ans=cnt;
res=0;
int k;
for(int i=0;i<cnt;i=k)
{
k=i+1;
for(int j=i+1;k<cnt;j++)
{
if(a[j].getime<=a[i].leftime)
k=j+1;
else
break;
}
res++;

}
printf("Case %d: %d %d\n",++cas,ans,res);
}
return 0;
}



标签:shoot,1.0,int,brother,FZU,Game,2144,mosquito,Fat
From: https://blog.51cto.com/u_15834522/5766288

相关文章

  • FZU 2140 Forever 0.5(找规律,几何)
    Problem2140Forever0.5Accept:371Submit:1307SpecialJudgeTimeLimit:1000mSecMemoryLimit:32768KBProblemDescriptionGivenanintegerN,y......
  • 体感游戏 | 手势识别玩飞机大战游戏(一) 用pygame实现飞机大战小游戏
        后面将分四篇文章来介绍实现手势识别控制飞机大战游戏的功能,它们分别是:使用Pygame实现简易飞机大战小游戏使用Python+OpenCV实现简单手势识别使用OpenCV实现手势识......
  • pygame-01的安装与基本框架
    1.pygame安装pipinstallpygame2.基本(代码)架运行体验importpygame,sys #引用游戏与系统库pygame.init()screen=pygame.display.set_mode((600,400)) #窗体大小......
  • atcoder ARC C 01-Game (博弈, Grundy数)
    https://atcoder.jp/contests/arc151/tasks/arc151_c题意:有1*n的的网格,有一些位置填有0和1,现在A和B进行游戏,往网格上填0/1,要保证相邻两个格子不能相同。A先手,问最后谁赢......
  • LeetCode877. Stone Game
    题意alice和bob又开始了方法先手稳赢代码classSolution{public:boolstoneGame(vector<int>&piles){returntrue;}};......
  • ARC151C 01 Game
    ARC151C01Game前言赛时机房大佬们以及标算都用SG函数做的,而我用的是最朴素的大力分类讨论,wa了十二发才过,写下这篇题解记录我的想法,纪念一下这场比赛。题目简意\(......
  • CF1628D1 Game on Sum (Easy Version)
    CF1628D1GameonSum(EasyVersion)-洛谷|计算机科学教育新生态(luogu.com.cn)个人认为博弈论的板子题。首先\(k\)就是个障眼法。当\(k\)变化的时候,Alice选......
  • A_Dice_Game
    Exungsh/A_Dice_Game软件工程结对编程作业ik&小鱼_bilibili一、结对探索1.1队伍基本信息结对编号:53队伍名称:做不出来吃大便学号姓名作业博客链接具体分工......
  • For gamers. BY GAMERS (dp预处理+二分)
    题目大意:给出n个类型的魔法,每个魔法需要可以给敌人造成伤害,给自己弄血,但是需要花费Ci,给你X个金币,询问m次,  给出怪兽的血和攻击,问最少许需要多少金币才......
  • CF1267G Game Relics
    题面传送门首先一个直觉肯定是先抽后买,因为越后抽的期望收益越小,因此将一个抽卡和一个买交换一定不优。然后另一个直觉是如果一次抽没有抽到,那么接下来一定接着抽。因为......