#P9730. Defend the Grading System

    ID: 22876 Type: Default 1000ms 256MiB

Defend the Grading System

Defend the Grading System

The competition committee has detected suspicious network activity — someone is trying to attack the judging system!

The judging system has a computational power of (c_G) and is protected by (f_G) firewalls. Each firewall reduces the impact of an attack by (S). The hacker wants to reduce (c_G) to (0) (or even lower).

At each moment, the hacker can choose one of the following two operations:

  • Break one of the system’s firewalls, thereby decreasing \(f_G\) by \(1\) (but not below \(0\)).
  • Attack the system with his entire computational power \(c_H\), reducing \(c_G\) by \(\max(c_H - f_G \cdot S,\ 0)\).
After the hacker’s move, the committee chairman can retaliate with one of two moves:
  • Break one of the hacker’s firewalls, decreasing \(f_H\) by \(1\) (but not below \(0\)).
  • Attack the hacker using the system’s computational power, reducing \(c_H\) by \(\max(c_G - f_H \cdot S,\ 0)\).
The hacker always makes the first move and then they take turns. Assuming that the committee chairman plays optimally, your task is to determine, for \(Q\) different scenarios (each described by a quadruple \((c_H, f_H, c_G, f_G)\)), whether the hacker can eventually reduce \(c_G\) to \(0\) or less.

inputFormat

The first line contains two integers (Q) and (S), where (Q) is the number of test cases and (S) is the firewall reduction factor. Each of the following (Q) lines contains four integers (c_H), (f_H), (c_G), and (f_G) representing the hacker’s computational power, the number of hacker firewalls, the system’s computational power, and the number of system firewalls respectively.

outputFormat

For each test case, output a single line containing either “Yes” if the hacker can reduce (c_G) to (0) or less (even with optimal counterattacks by the chairman), or “No” otherwise.

sample

4 1
3 1 5 2
6 5 2 10
10 1 15 2
5 10 20 10
No

Yes No No

</p>