2 shunfurh shunfurh 于 2017.08.30 20:27 提问

Lich

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

1个回答

caozhy
caozhy   Ds   Rxr 2017.09.15 00:19
已采纳
Csdn user default icon
上传中...
上传图片
插入图片