2113B.md (2456B)
1 Source: https://codeforces.com/problemset/problem/2113/B 2 3 B. Good Start 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 The roof is a rectangle of size $w \times h$ with the bottom left corner at the point $(0, 0)$ on the plane. Your team needs to completely cover this roof with identical roofing sheets of size $a \times b$, with the following conditions: 22 23 * The sheets cannot be rotated (not even by $90^\circ$). 24 * The sheets must not overlap (but they can touch at the edges). 25 * The sheets can extend beyond the boundaries of the rectangular roof. 26 27 A novice from your team has already placed two such sheets on the roof in such a way that the sheets do not overlap and each of them partially covers the roof. 28 29 Your task is to determine whether it is possible to completely tile the roof without removing either of the two already placed sheets. 30 31 Input 32 33 Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows. 34 35 The first line of each test case contains four integers $w$, $h$, $a$, and $b$ ($1 \le w, h, a, b \le 10^9$) — the dimensions of the roof and the dimensions of the roofing sheets, respectively. 36 37 The second line of each test case contains four integers $x_1$, $y_1$, $x_2$, and $y_2$ ($-a + 1 \le x_1, x_2 \le w - 1, -b + 1 \le y_1, y_2 \le h - 1$) — the coordinates of the bottom left corners of the already placed roofing sheets. It is guaranteed that these sheets do not overlap. 38 39 Output 40 41 For each test case, output "Yes" (without quotes) if it is possible to completely tile the roof without removing either of the two already placed tiles, and "No" (without quotes) otherwise. 42 43 You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses. 44 45 Example 46 47 Input 48 49 ``` 50 7 51 52 6 5 2 3 53 54 -1 -2 5 4 55 56 4 4 2 2 57 58 0 0 3 1 59 60 10 9 3 2 61 62 0 0 4 3 63 64 10 9 3 2 65 66 0 0 6 3 67 68 5 5 2 2 69 70 -1 -1 4 -1 71 72 5 5 2 2 73 74 -1 -1 2 3 75 76 7 8 2 4 77 78 0 0 0 5 79 ``` 80 81 Output 82 83 ``` 84 Yes 85 No 86 No 87 Yes 88 No 89 Yes 90 No 91 ``` 92 93 Note 94 95 In the first test case, it is possible to add $8$ roofing sheets as follows: 96 97  98 99 In the second test case, it is impossible to completely tile the roof: 100 101 