Orig Description
Problem K: Escape of Lappin the Phantom Thief
Problem
Lappin the Phantom Thief came to steal jewels. He easily obtained the jewels, but they were fitted with sensors and he was surrounded by security robots.
The security robots are programmed to move towards the jewels. Since the sensors were difficult to remove, he decided to leave the jewels and escape. He decided to place the jewels as far away from the security robots as possible and buy himself some time to escape.
The site is a rectangular shape consisting of n x m squares, and there are no obstacles.
There are k security robots placed at squares (xi, yi) (0 ≤ xi ≤ n−1, 0 ≤ yi ≤ m−1), and they can move one square up, down, left, or right in one unit of time.
The security robots will move to the jewels by the shortest path.
When you can freely place jewels in the site, find the maximum time taken by at least one security robot to reach a square with jewels.
Input
n m k
x1 y1
x2 y2
...
xk yk
All input is given as integers.
The first line contains three integers n, m, and k, separated by a single space.
The k lines following the first line contain the coordinates of the squares where the security robots are, (xi, yi), separated by a single space.
Constraints
1 ≤ n, m ≤ 5 × 104
1 ≤ k ≤ min(105, n × m)
0 ≤ xi ≤ n−1
0 ≤ yi ≤ m−1
The given coordinates are all different
Output
Output the maximum time taken by any security robot to reach a square with jewels on one line.
Sample Input 1
20 10 1
0 0
Sample Output 1
28
Sample Input 2
20 10 2
0 0
17 5
Sample Output 2
15
Sample Input 3
20 10 3
0 0
17 5
6 9
Sample Output 3
11
Extracted Specification
Canonicalized Input Description:
An integer n (1 ≤ n ≤ 5 × 10^4), representing some quantity or size.
An integer m (1 ≤ m ≤ 5 × 10^4), representing some quantity or size.
An integer k (1 ≤ k ≤ min(10^5, n × m)), representing some quantity or size.
A list of k pairs of integers (xi, yi), where 0 ≤ xi ≤ n−1 and 0 ≤ yi ≤ m−1.
### Example Input:
```
20 10 1
0 0
```
### Function Signature:
Write a function f(n, m, k, coordinates) that takes in the input.
def f(n: int, m: int, k: int, coordinates: List[Tuple[int, int]]):
'''
n: an integer
m: an integer
k: an integer
coordinates: a list of k pairs of integers
'''
Test Case Generator
Sure, I can help you write a test case generator for the problem "Escape of Lappin the Phantom Thief".
Here is a Python function to generate test cases for this problem:
```python
import random
def generate_test_case():
# Define constraints
n = random.randint(1, 5 * 10**4)
m = random.randint(1, 5 * 10**4)
k = random.randint(1, min(10**5, n * m))
# Generate k unique robot coordinates
robot_positions = set()
while len(robot_positions) < k:
x = random.randint(0, n - 1)
y = random.randint(0, m - 1)
robot_positions.add((x, y))
# Convert set to list
robot_positions = list(robot_positions)
# Format the test case
test_case = f"{n} {m} {k}\n"
for x, y in robot_positions:
test_case += f"{x} {y}\n"
return test_case.strip()
# Example usage
print(generate_test_case())
```
### Explanation:
1. **Constraints**:
- `n` and `m` are generated randomly within the range [1, 5 * 10^4].
- `k` is generated randomly within the range [1, min(10^5, n * m)].
2. **Generating Unique Robot Coordinates**:
- A set is used to ensure the robot coordinates are unique.
- Random coordinates are generated and added to the set until its size reaches `k`.
3. **Formatting the Output**:
- The test case is formatted as a string, with the first line containing `n`, `m`, and `k`.
- Each subsequent line contains the coordinates `xi` and `yi` of the robots.
This generator creates random test cases that adhere to the given constraints, which can be used to test the algorithm for the problem "Escape of Lappin the Phantom Thief".
Extract Arguments
def extract_arguments(fh):
n, m, k = map(int, fh.readline().strip().split())
coordinates = [tuple(map(int, fh.readline().strip().split())) for _ in range(k)]
return n, m, k, coordinates