Editorial for TLE '17 Contest 7 P1 - Stargazing
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
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:
Comments