编程介的小学生 2017-08-30 12:27 采纳率: 20.5%
浏览 851
已采纳

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条回答 默认 最新

  • threenewbee 2017-09-14 16:19
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退