Orig Description
Sunken Ruins in Hibara Sea
The Aizu Archaeological Society has embarked on an investigation of the ancient nation of Iwashiro, whose ruins lie beneath the Hibara Sea. The ruins exist in only one place in the Hibara Sea. Therefore, they decided to use a probing radar to estimate how far they need to investigate from the coastline by making an approximate estimate of the location of the ruins using a radar survey from the coastline.
Observation points are set on the coastline as shown in the figure above, and a probing radar is placed. With the probing radar, it is known that there are ruins in a semi-circular range of a certain size centered on the observation point. However, by combining multiple observation data, it is possible to narrow down the range even further.
Write a program that, given several observation data consisting of the position of the observation point and the radius shown by the probing radar, determines the maximum distance from the coastline that needs to be investigated.
Input
The input is given in the following format.
N
x1 r1
x2 r2
:
xN rN
The first line contains the number of data measured by the probing radar N (1 ≤ N ≤ 100000). Following are N lines, with an integer xi (0 ≤ xi ≤ 1,000,000) representing the position on the coastline of the i-th observation data in meters and an integer ri (1 ≤ ri ≤ 1,000,000) representing the radius within which the ruins exist from that position. The same observation data may be given more than once.
If more than one observation data is given, it can be assumed that there is always a point that falls within all of the semi-circles.
Output
Output the maximum distance from the coastline that needs to be investigated as a real number. The error should not exceed plus or minus 0.001 meters. Any number of decimal places can be displayed as long as this condition is met.
Sample Input 1
2
0 2
1 2
Sample Output 1
1.936
Sample Input 2
3
0 3
1 2
2 1
Sample Output 2
1.0
Sample Input 3
2
0 1
3 2
Sample Output 3
0.0
Extracted Specification
An integer N (1 ≤ N ≤ 100000), representing some quantity or size.
A list of N tuples, where each tuple contains two integers:
- The first integer xi (0 ≤ xi ≤ 1,000,000).
- The second integer ri (1 ≤ ri ≤ 1,000,000).
### Example Input:
```
2
0 2
1 2
```
### Function Signature:
Write a function f(inputs) that takes in the input.
```python
def f(inputs: List[Tuple[int, int]]):
'''
inputs: a list of tuples, where each tuple contains two integers
'''
```
Test Case Generator
Sure, I can help you write a test case generator for the "Sunken Ruins in Hibara Sea" problem. Here is a Python function that generates random test cases for this problem statement:
```python
import random
def tcgen():
N = random.randint(1, 100000) # number of observation data points
data = []
for _ in range(N):
xi = random.randint(0, 1000000) # position on the coastline
ri = random.randint(1, 1000000) # radius
data.append((xi, ri))
return N, data
# Helper function to print the test case in the required format
def print_test_case():
N, data = tcgen()
print(N)
for xi, ri in data:
print(xi, ri)
# Example usage
if __name__ == "__main__":
print_test_case()
```
### Explanation:
- **N**: Randomly generated integer between 1 and 100000, representing the number of observation data points.
- **xi**: Randomly generated integer between 0 and 1000000, representing the position on the coastline for the i-th observation.
- **ri**: Randomly generated integer between 1 and 1000000, representing the radius within which the ruins exist from the i-th observation point.
The `print_test_case` function calls `tcgen` to generate a test case and then prints it in the required format.
You can run this script to generate and print a random test case. Each time you run it, you will get a new random test case.
Extract Arguments
def extract_arguments(fh):
N = int(fh.readline().strip())
observations = []
for _ in range(N):
xi, ri = map(int, fh.readline().strip().split())
observations.append((xi, ri))
return observations