Orig Description
The Oldest Site
Problem
In the past, there was a village where many people lived. People built buildings of various shapes and sizes. However, those buildings are already lost, and only documents and pillars found in the ruins were a clue to the location of the buildings.
There is a description of the temple in the document. The temple is a square when viewed from above, and there were pillars at the four corners. It is not known which direction the temple was facing. Also, it is not known whether there were pillars on the sides or inside. Archaeologists believed that among the pillars found in the ruins, the one with the largest area that is square must be the temple.
Given the coordinates of the pillars, write a program that finds the square made up of four pillars with the largest area and outputs its area. Note that the sides of the square are not necessarily parallel to the coordinate axis.
Example
In the example of the figure below, there are ten pillars, and the four at coordinates (4, 2), (5, 2), (5, 3), and (4, 3) make a square, and the four at coordinates (1, 1), (4, 0), (5, 3), and (2, 4) also make a square. The latter square has the largest area of 10.
Input
The input consists of multiple datasets. Each dataset is given in the following format. The input is terminated by a line containing a single zero.
The first line contains the number of pillars n found in the ruins.
From the second line to the n + 1-th line, each of the n lines contains the x and y coordinates of a pillar separated by a space.
Each pillar appears only once or never.
n is an integer satisfying 1 ≤ n ≤ 3000, and the x and y coordinates of the pillars are integers between 0 and 5000 inclusive.
30% of the score is for datasets where 1 ≤ n ≤ 100, and 60% of the score is for datasets where 1 ≤ n ≤ 500.
There are no more than 10 datasets.
Output
For each dataset, output one integer. If there is a square made up of four pillars, output the area of the largest such square, and if there is no such square, output 0.
Sample Input
10
9 4
4 3
1 1
4 2
2 4
5 8
4 0
5 3
0 5
5 2
10
9 4
4 3
1 1
4 2
2 4
5 8
4 0
5 3
0 5
5 2
0
Sample Output
10
10
The problem statement and test data used in the automated judge are provided by Information-technology Promotion Agency, Japan.
Extracted Specification
An integer n (1 ≤ n ≤ 3000), representing some quantity or size.
n lines follow, each line containing two integers x and y (0 ≤ x, y ≤ 5000).
### Example Input:
```
10
9 4
4 3
1 1
4 2
2 4
5 8
4 0
5 3
0 5
5 2
```
### Function Signature:
Write a function f(inputs) that takes in the input.
```python
from typing import List, Tuple
def f(inputs: List[Tuple[int, int]]) -> None:
'''
inputs: a list of tuples, each containing two integers
'''
```
Test Case Generator
Sure! Below is a test case generator for the problem "The Oldest Site":
```python
import random
def generate_single_dataset():
n = random.randint(1, 3000)
pillars = set()
while len(pillars) < n:
x = random.randint(0, 5000)
y = random.randint(0, 5000)
pillars.add((x, y))
pillars_list = list(pillars)
dataset = f"{n}\n"
for (x, y) in pillars_list:
dataset += f"{x} {y}\n"
return dataset
def tcgen():
num_datasets = random.randint(1, 10) # Generate between 1 and 10 datasets
test_case = ""
for _ in range(num_datasets):
test_case += generate_single_dataset()
test_case += "0" # Termination line
return test_case
# Example usage:
print(tcgen())
```
This script generates random test cases for the problem "The Oldest Site". Let's break down what it does:
1. **generate_single_dataset()**:
- It generates a single dataset with a random number of pillars \( n \) (between 1 and 3000).
- It ensures that each pillar's coordinates are unique by using a set.
- The x and y coordinates are randomly chosen between 0 and 5000 inclusive.
2. **tcgen()**:
- It creates between 1 and 10 datasets.
- It appends each dataset to the final test case string.
- It adds a termination line (`0`) at the end of the test case string.
3. **Example usage**:
- You can print a generated test case to see the output.
You can run this script to generate random test cases for testing purposes.
Extract Arguments
def extract_arguments(fh):
datasets = []
while True:
n = int(fh.readline().strip())
if n == 0:
break
pillars = []
for _ in range(n):
x, y = map(int, fh.readline().strip().split())
pillars.append((x, y))
datasets.append((n, pillars))
return datasets
# if __name__ == "__main__":
# input_path = sys.argv[1]
# with open(input_path, 'r') as fh:
# inputs = extract_arguments(fh)
# for dataset in inputs:
# n, pillars = dataset
# f(n, pillars)