题目描述
为了保护科普卢星区的和平,大主教阿塔尼斯每时每刻都在指挥部队抗击肆虐的虫群。最近,阿塔尼斯把目光投向了又一颗布满虫群的星球。在这次行动中,阿塔尼斯计划使用狂热者铲除星球上的虫群威胁。
狂热者是星灵的基本近战兵种,每个狂热者有一个攻击力 atk 和一个攻击范围 r。在狂热者发动攻击时,他会冲向距离最近的异虫,在这只异虫处释放 3 次威力强大的旋风斩。若有多只距离最近的异虫,他会选择最早出现的那只。若当前没有存活的异虫,那么这只狂热者会在原地释放旋风斩。每次旋风斩会对所有与攻击者距离小于等于 r 的异虫进行攻击,对每只异虫造成 atk 的伤害(生命值减少 atk)。
当然,这些异虫也是不好惹的。每只异虫具有初始生命值 h,当生命值小于等于 0 时,该异虫将会死亡(并离开战场)。但是,在一次攻击中,若一只异虫受到 3 次旋风斩后仍未死亡,那么它将会对进攻的狂热者进行反击,使这个狂热者不得不离开战场。
在整个战役中,按照时间顺序依次发生了 n 个事件,事件有以下两种:
你作为阿塔尼斯的副官,想知道战场的最终情况:每个狂热者是否离开了战场,以及每只异虫是否死亡。
输入
第一行包含一个整数 n (1≤n≤2×103),代表事件的数量。
接下来 n 行,每行给出一种事件,格式为以下两种之一:
1 x y h,代表一个生命值为 h 的异虫出现在了坐标 (x,y)。
2 x y atk r,代表一个攻击力为 atk,攻击半径为 r 的狂热者被折跃到了坐标 (x,y),并立即进行攻击。
上述所有的x,y,r 均为整数,满足 0≤∣x∣,∣y∣,r≤108;所有的 atk,h 均为整数,满足 1≤atk,h≤108。
输出
输出 n 行,第 i 行表示第 i 个事件中出现的异虫或狂热者最终是否留在战场。Yes 表示异虫未死亡或狂热者未离开战场,No 表示异虫死亡或狂热者离开战场,大小写不敏感。
样例输入 Copy
5 1 0 0 4 1 0 1 8 2 1 0 1 1 2 1 0 1 1 2 1 0 1 1
样例输出 Copy
No No No No Yes
提示
在样例中,发生了如下事件:
因而,最终所有异虫死亡,只有狂热者 5 留在战场。
一个模拟题,注意一下double的精度不够,可以使用long long。
#include<bits/stdc++.h>
using namespace std;
const int N = 2e3 + 10;
const int mod = 1e9 + 7;
typedef long long ll;struct node
{int x, y;ll r;bool death;
}insect[N];
int type[N];
ll dis(int a, int b, int c, int d)
{return 1LL * (a - c) * (a - c) + 1LL * (b - d) * (b - d);
}
int main()
{
#ifdef LOCALfreopen("E:/", "r", stdin);
#endifint n;int cnt = 0, tot = 0;cin >> n;while (n--){++cnt;int op;scanf("%d", &op);if (op == 1)scanf("%d%d%lld", &insect[cnt].x, &insect[cnt].y, &insect[cnt].r), type[cnt] = 1;else{type[cnt] = 2;int x, y, atk, r;scanf("%d%d%d%d", &x, &y, &atk, &r);int k = 0;ll d = 1e18;for (int i = 1; i <= cnt; i++){if (type[i] == 1 && insect[i].r > 0){if (d > dis(x, y, insect[i].x, insect[i].y))d = dis(x, y, insect[i].x, insect[i].y), k = i;}}for (int i = 1; i <= cnt; i++){if (!insect[i].death && type[i] == 1 && 1LL * (insect[i].x - insect[k].x) * (insect[i].x - insect[k].x) + 1LL * (insect[i].y - insect[k].y) * (insect[i].y - insect[k].y) <= 1LL * r * r){insect[i].r -= 3LL * atk;if (insect[i].r <= 0)insect[i].death = 1;elseinsect[cnt].death = 1;}}}}for (int i = 1; i <= cnt; i++)puts(!insect[i].death ? "Yes" : "No");return 0;
}
本文发布于:2024-02-02 05:38:05,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170682348541711.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |