Three Points solution codechef
There are three distinct points –in the plane. Initially, you are located at point . You want to reach the point satisfying the following conditions:
- You have to go through point B.
- You can move in any of the four axis-parallel directions ( , , , direction). However, you can make at most one turn in the path from to .
Determine if it is possible to reach the destinationsatisfying the above conditions.
- One turn means clockwise or anticlockwise rotation along the direction of movement. For example, if you are moving towards the direction, after one turn you can move either in the direction or in the direction. Changing the direction by is not allowed.
Input Format Three Points solution codechef
- The first line of input contains a single integer denoting the number of test cases. The description of test cases follows.
- The first line of each test case contains two space-separated integers , denoting the coordinates of the starting point A.
- The second line of each test case contains two space-separated integers , denoting the coordinates of the point B.
- The third line of each test case contains two space-separated integers , denoting the coordinates of the finishing point C.
Output Format Three Points solution codechef
For each test case, print a single line containing one string –
"YES"(without quotes) if it is possible to reach the finishing point satisfying the above conditions, otherwise print
Constraints Three Points solution codechef
- The three points are pairwise distinct
Sample Input 1
4 1 1 1 3 3 3 0 0 2 2 3 4 5 2 3 2 1 2 1 1 -1 1 10000 10000
Sample Output 1
YES NO YES NO
Test case: You start moving in the direction from , after two-unit steps you reach the point . Then you make a clockwise turn at point and start moving towards the direction. After two-unit steps, you reach the finishing point .
Test case: There is no possible way to reach the finishing point satisfying the above conditions. You have to make at least two turns in the path.
Test case: You start moving in the direction from . After 4 unit steps, you reach the finish point . In the path from to , you go through the point and don’t make any turn.
Solution: Click here