Problem p00318 - Generation 2

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:
- First integer xi (0 ≤ xi ≤ 1,000,000)
- 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.
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 generate a test case generator for the provided competitive programming problem. Below is a Python script that randomly generates test cases according to the problem's constraints.

```python
import random

def tcgen():
    # Number of observation data measured by the probing radar
    N = random.randint(1, 100000)
    
    # List to store the observation data
    observation_data = []
    
    for _ in range(N):
        xi = random.randint(0, 1000000)
        ri = random.randint(1, 1000000)
        observation_data.append((xi, ri))
    
    return N, observation_data

def format_test_case(N, observation_data):
    # Format the test case to match the input description
    formatted_data = "\n".join(f"{xi} {ri}" for xi, ri in observation_data)
    return f"{N}\n{formatted_data}"

# Example usage
N, observation_data = tcgen()
test_case = format_test_case(N, observation_data)
print(test_case)
```

What this script does:

1. `tcgen()` function generates the number of data points `N` and a list of tuples where each tuple contains the position `xi` and the radius `ri`.
2. The `format_test_case()` function takes the generated `N` and observation data and formats it into the required input format as a string.
3. The example usage at the bottom generates a test case and prints it.

You can run this script to generate different test cases for the problem. Make sure to use proper constraints as specified in the problem statement when integrating with your competitive programming setup.

Extract Arguments

def extract_arguments(fh):
    N = int(fh.readline().strip())
    data = []
    for _ in range(N):
        x, r = map(int, fh.readline().strip().split())
        data.append((x, r))
    return N, data