Lich

来源:互联网 发布:qt中混合c 编程 编辑:程序博客网 时间:2024/06/05 00:47

Dota是在一款有名的游戏“魔兽争霸3”中的一类地图。它非常有趣,所以很多ZJUers都很喜欢它,我也是其中之一。

Lich是我在Dota游戏中喜欢选择使用的其中一位英雄,他有着使用冰霜对其敌人产生巨大伤害的能力。Lich是一位冷血杀手。他最可怕的技能是“链式冰霜”。当使用这个技能时,Lich将会释放一个不断跳跃的且能反弹少许几次的“冰霜吐吸”。冰霜将会随机的在一定范围内的单位之间来回的反弹,并且每次打击产生一定量的伤害。

当我使用这个英雄的时候,我总是想知道:我是否能够通过使用这个终极技能杀死敌方英雄。虽然我是一个计算机科学系的学生,但是我并不擅长编程。所以我求助于你,天才的ACM选手。

假定Lich和敌方英雄(仅一个)处在一个二维地图中。有N个英雄在这个地图上,第一个英雄是Lich而最后一个英雄是敌方英雄。Lich仅能使用“链式冰霜”一次。“链式冰霜”将首先打击与Lich之间的距离不大于R的那个单位,同时产生D的伤害。然后这个冰霜将会随机的在R范围内的存活单位(但不包括Lich本身)之间来回反弹并且每次打击产生D的伤害。这个冰霜将不会反弹超过K次。

注意,那个冰霜必需从一个单位反弹到另一个单位,否则它将终止。而且当这个“链式冰霜”打击某个人A后,下一次它必需反弹到另一个存活的单位B上,并且单位A与单位B的距离不能超过R,否则它也会终止。

每个单位都有一个健康点数(HP),当某个单位的HP不大于0时,则该单位已经被打败。而当一个单位被打败后,他将被从地图中移除,再不能更多的被冰霜打击。

输入

第一行是测试用例数T(0 <= T <= 300)。每个测试用例都以一个包含四个正整数的行开始,N R K D (3 <= N <= 1000, R K D <= 30000)。然后接着N行,每一行都包括三个非负整数:Xi, Yi, Hi (Xi Yi Hi <= 30000, Hi >= 1)。Xi、Yi是这个英雄的水平坐标和垂直坐标,而Hi则是他的HP。

每个测试用例之后都有一个空行。

输出

对于每个测试用例,输出仅有一行。如果Lich打败敌方英雄是可能的,输出“YES”,否则,输出“NO”。每个输出结果后打印一个空行。

输入样例

3
3 1 6 100
0 0 1200
0 1 300
0 2 300

3 1 5 100
0 0 1200
0 1 300
0 2 300

3 1 6 100
0 0 1200
0 1 200
0 2 300

输出样例

YES

NO

NO

---------------------------------------------------以下是原文---------------------------------------------------

Dota is a kind of map in the famous game Warcraft 3. It 's so interesting that many ZJUers are fond of it. I am one of those happy guys.

Lich is one of the heroes that I would like to choose to use in the Dota game. He has the power to use frost to cause tremendous pain to his enemy. The Lich is a murderer without a trace of warmth. His most terrified skill is Chain Frost. When using it, the lich will release a jumping breath of frost that can bounce for a few times. Frost will randomly bounce back and forth between units that are within some range and cause some damage per hit.

When I use this hero, I always want to know: can I kill the enemy heroes by using this terminal skill. Though I am a computer science student, I am not good at programing. So I turn to you, the talented ACM player.

Suppose that the lich and the enemy hero(only one) stand in a two dimension map. There are N heroes in the map. The first hero is the lich and the last hero is the enemy hero. The lich can use Chain Frost only once. The Chain Frost will first hit the one which has a distance no more than R from the lich and cause D damage. Then the frost will randomly bounce back and forth between alive units(but not lich himself) that are within R range and cause D damage per hit. The frost will not bounce more than K times.

Notice that the frost must bounce from one unit to the other, or it will stop. And when the Chain Frost hits some person A, the next time it must bounce to the other person alive B, and the distance between A and B must be no more than R, or it will stop too.

Every one have a health point(HP), and when one's health point is no more than 0, he is defeated. And when one is defeated he will be removed from the map and can't be hit by the frost any more.

Input

The first line is the num of cases T(0 <= T <= 300). Each test case starts with a line, which contains 4 positive integers, N R K D (3 <= N <= 1000, R K D <= 30000). Then N lines follow, each contain three non-negative integers: Xi, Yi, Hi (Xi Yi Hi <= 30000, Hi >= 1). Xi Yi is the horizontal coordinate and vertical coordinate and of the hero and Hi is his health point.

There is a blank after each case.

Output

For each case, just output one line. If it is possible for the lich to defeat the enemy hero, output "YES", else output "NO". Print one blank after each case.

Sample Input

3
3 1 6 100
0 0 1200
0 1 300
0 2 300

3 1 5 100
0 0 1200
0 1 300
0 2 300

3 1 6 100
0 0 1200
0 1 200
0 2 300


Sample Output

YES

NO

NO