0% found this document useful (0 votes)
41 views

Strange Constellations (Constellation) : OIS2022 - Round 4

Stefan is interested in finding parallel L-shaped constellations among stars in the night sky. The input provides the positions of N stars as coordinates (xi, yi). A parallel L-shaped constellation consists of three stars forming an L-shape with sides parallel to the x- or y-axis. The task is to write a program to count the number of parallel L-shaped constellations given the star positions. The output is a single integer providing the number of constellations. Sample test cases and constraints on N and coordinate values are provided.

Uploaded by

moha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Strange Constellations (Constellation) : OIS2022 - Round 4

Stefan is interested in finding parallel L-shaped constellations among stars in the night sky. The input provides the positions of N stars as coordinates (xi, yi). A parallel L-shaped constellation consists of three stars forming an L-shape with sides parallel to the x- or y-axis. The task is to write a program to count the number of parallel L-shaped constellations given the star positions. The output is a single integer providing the number of constellations. Sample test cases and constraints on N and coordinate values are provided.

Uploaded by

moha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

O I ( ) OIS2022 – Round 4 

; + + S Online, February 3rd, 2022 constellation • EN

Strange Constellations (constellation)


Back when he was little, Stefan used to look a lot at the sky during the night, hoping to see various kinds
of stars and to imagine different kinds of shapes which can be drawn amongst them. Looking back at his
childhood, he realized that he can now use the computer to refine this process!

Figure 1: Is that a horse?

Therefore, he gives you the 2D map of the stars during one particular night, and he tells you that there
were N stars on the sky. Furthermore, he also tells you the position (xi , yi ) of each star.
Stefan is interested in finding parallel L-shaped constellations. A parallel L-shaped path is a sequence
of three stars which form an L-shape and each side is parallel to the coordinate axes. The L can have
its sides rotated, as long as it still forms an L. Furthermore, the L can’t be degenerated (i.e. a straight
line or a dot).
Help Stefan find the number of parallel L-shaped constellations in the given star map!

☞ Among the attachments of this task you may find a template file constellation.* with a
sample incomplete implementation.

Input
The first line contains the only integer N .
The next N line contains 2 integers xi and yi .

Output
You need to write a single line with an integer: the number of parallel L-shaped constellation.

Constraints
• 1 ≤ N ≤ 200 000.
• 1 ≤ xi , yi ≤ 200 000 for each i = 0 . . . N − 1.

constellation Page 1 of 2
Scoring
Your program will be tested against several test cases grouped in subtasks. In order to obtain the score
of a subtask, your program needs to correctly solve all of its test cases.
– Subtask 1 (0 points) Examples.

– Subtask 2 (25 points) N ≤ 200.

– Subtask 3 (40 points) N ≤ 2000.

– Subtask 4 (35 points) No additional limitations.


Examples
input output

6 4
5 5
8 5
5 8
3 3
5 1
0 5

Explanation
In the first sample case there are 4 L-shaped constellation.
y y
9 9

8 8

7 7

6 6

5 5

4 4

3 3

2 2

1 1

0 0
0 1 2 3 4 5 6 7 8 9 x 0 1 2 3 4 5 6 7 8 9 x
y y
9 9

8 8

7 7

6 6

5 5

4 4

3 3

2 2

1 1

0 0
0 1 2 3 4 5 6 7 8 9 x 0 1 2 3 4 5 6 7 8 9 x

constellation Page 2 of 2

You might also like