Problem p02556 - Generation 3

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.
N pairs of integers (x_i, y_i), where 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.
def f(N: int, points: List[Tuple[int, int]]):
    ''' 
    N: an integer 
    points: a list of tuples, each containing two integers
    '''

Test Case Generator

Here's the test case generator for the provided problem statement:

```python
import random

def tcgen():
    N = random.randint(2, 2 * 10**5)
    
    points = [(random.randint(1, 10**9), random.randint(1, 10**9)) for _ in range(N)]
    
    return N, points

# Example of generating and printing a test case
def print_test_case():
    N, points = tcgen()
    print(N)
    for x, y in points:
        print(x, y)

# Generate and print a test case
print_test_case()
```

This function `tcgen` generates a random test case for the problem. It selects a random number \( N \) of points within the given constraints, then generates \( N \) points with coordinates within the range [1, \( 10^9 \)]. The `print_test_case` function prints the generated test case in the required format.

To use this generator, simply call `print_test_case`, and it will print a randomly generated test case to the standard output. You can modify this function to store test cases in a file or use them in any other way as per your needs.

Extract Arguments

def extract_arguments(fh):
    N = int(fh.readline().strip())
    points = [tuple(map(int, fh.readline().strip().split())) for _ in range(N)]
    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)