Orig Description
Score : 500 points
Problem StatementThere are N points on the 2D plane, i-th of which is located on (x_i, y_i).
There can be multiple points that share the same coordinate.
What is the maximum possible Manhattan distance between two distinct points?
Here, the Manhattan distance between two points (x_i, y_i) and (x_j, y_j) is defined by |x_i-x_j| + |y_i-y_j|.
Constraints
2 \leq N \leq 2 \times 10^5
1 \leq x_i,y_i \leq 10^9
All values in input are integers.
InputInput is given from Standard Input in the following format:
N
x_1 y_1
x_2 y_2
:
x_N y_N
OutputPrint the answer.
Sample Input 13
1 1
2 4
3 2
Sample Output 14
The Manhattan distance between the first point and the second point is |1-2|+|1-4|=4, which is maximum possible.
Sample Input 22
1 1
1 1
Sample Output 20
Extracted Specification
An integer \(N\) (2 ≤ \(N\) ≤ 2×10^5), representing some quantity or size.
A list of \(N\) tuples, each containing two integers (1 ≤ \(x_i\), \(y_i\) ≤ 10^9).
### Example Input:
```
3
1 1
2 4
3 2
```
### Function Signature:
Write a function f(N, points) that takes in the input.
```python
def f(N: int, points: List[Tuple[int, int]]):
'''
N: an integer
points: a list of tuples, each containing two integers
'''
```
Test Case Generator
Certainly! Here’s a test case generator for the problem statement you provided:
```python
import random
def tcgen():
# Generate a random number of points between 2 and 200,000
N = random.randint(2, 200000)
# Generate N points with random coordinates between 1 and 10^9
points = [(random.randint(1, 10**9), random.randint(1, 10**9)) for _ in range(N)]
return N, points
def format_test_case(N, points):
# Convert points into the required input format
test_case = f"{N}\n" + "\n".join(f"{x} {y}" for x, y in points)
return test_case
# Example usage
N, points = tcgen()
test_case = format_test_case(N, points)
print(test_case)
```
This script will generate a test case for the provided problem statement, including:
1. A random integer \( N \) within the given constraints.
2. A list of \( N \) points with coordinates randomly selected between 1 and \( 10^9 \).
The `tcgen` function generates the data, while `format_test_case` converts it into the required input format.
The example usage at the end demonstrates how you can generate and print a test case. You can integrate this into your testing environment to generate multiple test cases as needed.
Extract Arguments
def extract_arguments(fh):
N = int(fh.readline().strip())
points = []
for _ in range(N):
x, y = map(int, fh.readline().strip().split())
points.append((x, y))
return N, points
# if __name__ == "__main__":
# input_path = sys.argv[1]
# with open(input_path, 'r') as fh:
# N, points = extract_arguments(fh)
# f(N, points)