Perpendicular Lines
Practice
3.4 (9 votes)
Easy
Math
Problem
17% Success 7837 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code
Given 4 points of the form (xi, yi) in 2D plane, find out if the lines formed by (x1, y1), (x2, y2) and (x3, y3), (x4, y4) are perpendicular to each other.
NOTE:
- It is NOT provided that the points are distinct i.e the first two or the last two points may be equal too!
INPUT FORMAT:
First line T is the number of test cases. Each test case is followed by 2 lines.
The first line of every test case contains four integers (x1, y1) and (x2, y2).
The second line contains four integers (x3, y3) and (x4, y4).
OUTPUT FORMAT:
For every test case :
- print "YES" without quotes if the lines are perpendicular to each other
- print "NO" without quotes if the lines are not perpendicular
- print "INVALID" without quotes if there are less than 2 lines
CONSTRAINTS:
1 <= T <= 10^5
-10^18 <= xi <= 10^18
-10^18 <= yi <= 10^18
Submissions
Please login to view your submissions
Similar Problems
Points:20
24 votes
Tags:
Basic ProgrammingBasics of ImplementationEasyImplementationString Manipulationstring manipulation
Points:20
20 votes
Tags:
ArraysBasic ProgrammingEasy
Points:20
186 votes
Tags:
Ad-HocEasyMathOpen
Editorial