Rectangle Counting
Author: QuwsarOhi
Problem Setter: Md Farid MiahIntake 32, Department of CSE
In the initial version or v1.0.0, you are given an N*M grid. Then count the number of rectangles in this grid by using the simple equation . In the next version v1.1.0, you are given N points then calculate how many rectangles are formed by these points. It is guaranteed that all rectangles are parallel to the axis.
Example: (0,0),
(0,1), (1,1), (1,0), (2,0) and (2,1) number of rectangles are 3. Left rectangle
(0,0), (0,1), (1,1), (1,0) right rectangle (1,0), (1,1), (2,1), (2,0) and big
rectangle (0,0), (0,1), (2,1), (2,0).
Input Format
The first line contains one integer N (1 <= N <= 1000) - the number of points. Then next N lines
contain X and Y (-109≤ X, Y≤109 ) - coordinates of the X and Y-axis.
Output Format
Calculate
the number of rectangles is forme d/shaped by these N points.
Samples
Input
Output
Input
Output
Language | Time | Memory |
GNU C 11 | 1s | 512MB |
GNU C++ 14 | 1s | 512MB |
GNU C++ 11 | 1s | 512MB |