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, each containing two integers (xi, ri).
- xi (0 ≤ xi ≤ 1,000,000)
- 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 as a list of tuples.
```python
def f(inputs: List[Tuple[int, int]]):
'''
inputs: a list of tuples, where each tuple contains two integers
'''
```
Test Case Generator
Certainly! To generate test cases for the "Sunken Ruins in Hibara Sea" problem, we need to create random test data following these constraints:
1. An integer \(N\) (1 ≤ \(N\) ≤ 100,000) representing the number of observation data points.
2. For each data point, an integer \(x_i\) (0 ≤ \(x_i\) ≤ 1,000,000) representing the position on the coastline, and an integer \(r_i\) (1 ≤ \(r_i\) ≤ 1,000,000) representing the radius of the semi-circle.
Here is a Python test case generator for this problem:
```python
import random
def tcgen():
# Generate random N within the specified range
N = random.randint(1, 100000)
# Generate N pairs of (xi, ri) within the specified ranges
observation_data = []
for _ in range(N):
x_i = random.randint(0, 1000000)
r_i = random.randint(1, 1000000)
observation_data.append((x_i, r_i))
# Print the generated test case
print(N)
for x_i, r_i in observation_data:
print(f"{x_i} {r_i}")
# Example usage:
tcgen()
```
This function generates a random number of observations \(N\) and then creates \(N\) pairs of \(x_i\) and \(r_i\) values within their respective ranges. It prints out the test case in the required format.
For real-world competitive programming, you might want to save these test cases to a file or use them in a specific testing framework. This script simply prints the generated test case to the console. If you need to save it to a file, you could modify the function like this:
```python
import random
def tcgen(filename):
with open(filename, 'w') as f:
# Generate random N within the specified range
N = random.randint(1, 100000)
# Write N to the file
f.write(f"{N}\n")
# Generate N pairs of (xi, ri) within the specified ranges
for _ in range(N):
x_i = random.randint(0, 1000000)
r_i = random.randint(1, 1000000)
f.write(f"{x_i} {r_i}\n")
# Example usage:
tcgen('test_case.txt')
```
This version writes the test case to a file named 'test_case.txt'. This could be useful for creating multiple test cases and organizing them in a structured manner for further testing.
Extract Arguments
def extract_arguments(fh):
N = int(fh.readline().strip())
observations = []
for _ in range(N):
x, r = map(int, fh.readline().strip().split())
observations.append((x, r))
return N, observations