DistantPoints
TCO10 Semi 1 · 2010-04-11 · by gojira_tc
Problem Statement
Notes
- The Euclidean distance between two points (x1,y1) and (x2,y2) is equal to the square root of (x1-x2)^2+(y1-y2)^2.
Constraints
- N will be between 2 and 10, inclusive.
- K will be between 1 and the amount of points inside the square with side length 2^N+2, inclusive.
Statement by TopCoder, Inc. — view the original on the archive.
4
2
Returns: {17, 17 }
The square stretches from (0,0) to (18,18). After you paint (1,1), the farthest point within the square is (17,17).
4
3
Returns: {1, 17 }
Now there are two candidates. Both upper-left and bottom-right points within the square are equally distant from the already painted two, so we choose the leftmost one.
4
5
Returns: {9, 9 }
After you paint all the corners, the best choice is the center of the square.
3
14
Returns: {1, 3 }
5
1089
Returns: {33, 32 }
Submissions are judged against all 186 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class DistantPoints with a public method vector<int> getKth(int N, int K) · 186 test cases · 2 s / 256 MB per case