Points and Lines codechef Question:-
Givenpoints of the form on a -D plane.
From each point, you drawlines one horizontal and one vertical. Now some of the lines may overlap each other, therefore you are required to print the number of distinct lines you can see on the plane.
- Two horizontal lines are distinct if they pass through different coordinates.
- Two vertical lines are distinct if they pass through different coordinates.
- First line will contain , number of testcases. Then the testcases follow.
- Each testcase contains a single integer , the number of points.
- The next lines contain two space separated integers , the coordinate of the point.
For each testcase, output in a single line the number of distinct lines that can be seen on the plane.
- Sum of over all test cases is atmost .
Sample Input 1
3 4 1 1 1 0 0 1 0 0 5 0 0 0 1 0 2 0 3 0 4 1 10 10
Sample Output 1
4 6 2
Test Case: There are horizontal lines passing through and , and vertical lines passing through and .
Test Case: There are horizontal lines passing through and and vertical line passing through .
Test Case: There is horizontal line passing through and vertical line passing through .
Code of Points and Lines codechef:-
t=int(input()) for j in range(t): h= v= ans=0 n=int(input()) for i in range(n): e=input().split() h.append(e) v.append(e) if e==1 and e==0: ans+=1 h=list(set(h)) v=list(set(v)) ans=ans+len(h)+len(v) print(ans)
Points and Lines codechef
- c program to convert specified days into years weeks and days
- Print Reverse Hollow Pyramid
- Update the booking ID | Wipro previous year question paper
- Pages in PDF | Wipro previous year question paper
- Sparse Matrix in data structure
- Find the location ID | Wipro previous year Coding question
- find the odd digits | Wipro Coding question
- Find the product id | Wipro Coding question
- Difference between static and dynamic memory allocation
- What is asymptotic Notation