#P1170. 兔八哥与猎人

兔八哥与猎人

Description

Bugs Bunny is hiding in an orchard next to a forest. The orchard has M×NM \times N trees arranged in an MM-row by NN-column grid, and the distance between two horizontally or vertically adjacent trees is 11. Bugs Bunny is under one of the trees.

A hunter carrying a shotgun enters the orchard. He climbs onto a fruit tree, preparing to kill Bugs Bunny.

If there is no other fruit tree on the line segment connecting the hunter’s position and Bugs Bunny’s position, then the hunter can see Bugs Bunny.

Given the positions of the hunter and Bugs Bunny, write a program to determine whether the rabbit’s position is safe.

Input Format

The first line contains nn, the number of test cases. For each test case, the first line contains two positive integers axa_x and aya_y, representing the hunter’s position, and the second line contains two positive integers bxb_x and byb_y, representing Bugs Bunny’s position.

Output Format

Output nn lines. Each line contains yes or no, indicating whether Bugs Bunny’s position is safe.

1
1 1
1 2
no

Hint

1n1051 \le n \le 10^5, 1ax,ay,bx,by1081 \le a_x, a_y, b_x, b_y \le 10^8.

It is guaranteed that Bugs Bunny and the hunter are not at the same position.

Translated by ChatGPT 5