编程介的小学生 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 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用