RadarFinder
SRM 349 · 2007-05-15 · by erinn
Problem Statement
You are the commander of a military operation that is focused on determining the location of an enemy unit. Two radar stations have provided measurements of their calculated distance from the enemy unit. You are given the locations of your radar stations in
You are to return an
Constraints
- x1 will be between -1000000000 and 1000000000, inclusive.
- y1 will be between -1000000000 and 1000000000, inclusive.
- r1 will be between 1 and 1000000000, inclusive.
- x2 will be between -1000000000 and 1000000000, inclusive.
- y2 will be between -1000000000 and 1000000000, inclusive.
- r2 will be between 1 and 1000000000, inclusive.
0 0 13 40 0 37 Returns: 2
The points (5, 12) and (5, -12) are the only points that are consistent with both radar measurements.
0 0 3 0 7 4 Returns: 1
Only one point, (0, 3), is consistent with both measurements.
0 0 5 10 10 3 Returns: 0
Perhaps one of the measurements was incorrect, since no points are consistent.
0 0 1 0 0 1 Returns: -1
Getting two identical readings from the same location still leaves an unlimited number of possible locations.
0 0 5 2 0 4 Returns: 2
Submissions are judged against all 304 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class RadarFinder with a public method int possibleLocations(int x1, int y1, int r1, int x2, int y2, int r2) · 304 test cases · 2 s / 256 MB per case