ZZULIOJ 2692: 我得重新集结部队

2692: 我得重新集结部队icon-default.png?t=M3K6http://acm.zzuli.edu.cn/problem.php?id=2692

#include<bits/stdc++.h>
using namespace std;
struct node
{
	int type;//虫=1,狂=2
	long long x,y,h,atk,r;
	int liu; ==2时狂离开
}p[3000];

int main()
{
	int n;cin>>n;
	int o=-1;
	while(n--)
	{
		o++;
		int t;cin>>t;
		if(t==1)
		{
			p[o].type=1;
			cin>>p[o].x>>p[o].y>>p[o].h;
		}
		else
		{
			p[o].type=2;
			cin>>p[o].x>>p[o].y>>p[o].atk>>p[o].r;
			long long  a=-1,ans=1e18;
			for(int i=0;i<=o;i++)
			{
				if(p[i].type==1&&p[i].h>0)
				{
					long long  rr=abs((p[i].x-p[o].x)*(p[i].x-p[o].x)+(p[i].y-p[o].y)*(p[i].y-p[o].y));//计算与狂距离最近的虫子
					if(rr<ans)
					{
						ans=rr;
						a=i;记录虫的序号
					}		
				}
			
			}
			if(a==-1) continue;
			p[o].x=p[a].x,p[o].y=p[a].y;狂到最近虫的坐标
			for(int i=0;i<=o;i++)
			{
				long long  rr=abs((p[i].x-p[o].x)*(p[i].x-p[o].x)+(p[i].y-p[o].y)*(p[i].y-p[o].y));
				if(p[i].type==1&&p[i].h>0&&rr<=p[o].r*p[o].r)
				{
					p[i].h-=3*p[o].atk;
					if(p[i].h>0)
						p[o].liu=2;//当虫子没有被杀死的时候,liu==2狂离开
					else
						p[i].h=0;//当虫子被杀的时候h==0;
					
				}
			}
		}
	}
	for(int i=0;i<=o;i++)
	{
		if(p[i].type==1)
		{
			if(p[i].h>0) cout<<"Yes"<<endl;
			else cout<<"No"<<endl;
		}
		else
		{
			if(p[i].liu==2) cout<<"No"<<endl;
			else cout<<"Yes"<<endl;
		}
	}
	return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值