|Submit||All submissions||Best solutions||Back to list|
RECTANGL - Rectangles
You are given a set S of N points in the plane and must count the number of distinct axis-parallel rectangles whose four vertices all lie in S (that is, count those rectangles which have two sides parallel to the x-axis, and the other two sides parallel to the y-axis).
The first line of the input is N (1 ≤ N ≤ 250000), the number of points in S. N lines then follow, where the i-th line is of the form "xi yi", giving the coordinates of a point (xi, yi) in S. All given points are distinct, and all coordinates fit into a 32-bit signed integer.
Your output should consist of a single number, the number of distinct axis-parallel rectangles whose four vertices all lie in S, followed by a newline.
Input: 6 -1 0 -1 1 0 0 0 1 1 0 1 1 Output: 3
|Cluster:||Cube (Intel G860)|
|Languages:||ADA95 ASM32 BASH BF C CSHARP CPP C99 CLPS LISP clisp LISP sbcl D FORTRAN HASK ICON ICK JAVA LUA NEM NICE OCAML PAS-GPC PAS-FPC PERL PHP PIKE PRLG-swi PYTHON RUBY SCM guile SCM qobi ST TEXT WHITESPACE|
|Resource:||MIT Individual Contest 2007|