Editorial for TLE '17 Contest 7 P1 - Stargazing
Submitting an official solution before solving the problem yourself is a bannable offence.
Use two arrays to keep track of the and coordinates for every planet. Let the first planet be located at the origin . For each other planet, calculate its and coordinates relative to the first planet, using the and coordinates of a previously located planet:
After that, there are two main ways to count the number of distinct pairs of coordinates:
Insert all the pairs of coordinates into a set. The size of the set will be your answer. Time Complexity:
For each planet, loop through all previous planets to check if their coordinates match. If that new planet is unique so far, increment your answer by one. Time Complexity: