Problem p00146 - Generation 3

Orig Description

Lupin III
Lupin III, a famous thief, hears from a beautiful woman named Fujimineko, who is a descendant of an Aizu clan samurai, that the Aizu clan left behind military funds in Aizu-Wakamatsu City. According to the report of Ishikawa Goemon, Lupin's long-time companion, the military funds are stored in several warehouses in wooden boxes. The warehouses are not guarded, but they are locked securely. However, if Goemon uses the secret technique "Steel Cutting" that he learned from his father, he can break open the warehouses in an instant.
The remaining problem is the transportation of the wooden boxes. Lupin and Goemon, who lack physical strength, cannot carry even one wooden box. Therefore, they rely on a dependable man named Mugen Daisuke for transportation.
To transport all the wooden boxes, Lupin devises the following plan:
First, Lupin will drive to the first warehouse and drop off Goemon and Daisuke.
Goemon breaks open the warehouse.
Daisuke carries all the wooden boxes.
Lupin heads to the next warehouse with the wooden boxes.
This is repeated until all the warehouses are broken open and the wooden boxes are transported. During this time, Lupin prepares a helicopter and carries Goemon, Daisuke, and the wooden boxes to the last warehouse, then escapes. Daisuke can carry anything, no matter how heavy, but his speed decreases depending on the weight of the luggage. Lupin must determine the order in which to break open the warehouses, taking this into account.
On behalf of Lupin, write a program that outputs the order in which to break open the warehouses so that the time from breaking open the first warehouse to reaching the last warehouse is minimized. However,
The warehouses all face a street that runs straight north from Tsuruga Castle. There are at most 15 warehouses, and they are all within 10,000 meters of the castle.
Each wooden box weighs 20 kilograms. There are at most 10,000 wooden boxes stored in each warehouse.
Transportation from warehouse to warehouse is done through an underground passage that runs along the street.
Daisuke moves at a rate of 2,000 / (70 + w) meters per minute when carrying a load of w kilograms.
For each warehouse, the input consists of the warehouse number (an integer up to 100), the distance from the castle in meters (an integer between 1 and 10,000), and the number of wooden boxes stored in the warehouse (an integer between 1 and 10,000).
Input
The input is given in the following format.
n
s1 d1 v1
s2 d2 v2
:
sn dn vn
The first line contains the number of warehouses, n (n ≤ 15), and the following n lines describe the warehouses. Each line gives the warehouse number si (1 ≤ si ≤ 100), the distance from the castle di (1 ≤ di ≤ 10,000), and the number of wooden boxes stored in the warehouse vi (1 ≤ vi ≤ 10,000).
Output
Output the order in which to break open the warehouses on a single line, separated by spaces.
Sample Input 1
2
1 100 1
2 200 2
Output for the Sample Input 1
1 2
Sample Input 2
3
11 100 1
13 200 20
12 300 3
Output for the Sample Input 2
11 12 13
Sample Input 3
5
13 199 1
51 1000 1
37 350 10
27 300 2
99 200 1000
Output for the Sample Input 3
51 37 27 13 99

Extracted Specification

    
Canonicalized Input Description:

An integer \( n \) (1 ≤ \( n \) ≤ 15), representing some quantity.

A list of \( n \) tuples, where each tuple contains:
  - An integer \( s \) (1 ≤ \( s \) ≤ 100),
  - An integer \( d \) (1 ≤ \( d \) ≤ 10,000),
  - An integer \( v \) (1 ≤ \( v \) ≤ 10,000).

### Example Input:

```
3
11 100 1
13 200 20
12 300 3
```

### Function Signature:
Write a function f(n, warehouses) that takes in the input.
```python
def f(n: int, warehouses: List[Tuple[int, int, int]]):
    '''
    n: an integer
    warehouses: a list of tuples, each containing three integers
    '''
```

Test Case Generator

To create a test case generator for the "Lupin III" problem, we need to consider the constraints and generate random input values that adhere to these constraints. Here is a Python function that generates random test cases for this problem:

```python
import random

def tcgen():
    # Number of warehouses (1 ≤ n ≤ 15)
    n = random.randint(1, 15)

    warehouses = []
    for _ in range(n):
        # Warehouse number (1 ≤ si ≤ 100)
        s = random.randint(1, 100)
        # Distance from the castle (1 ≤ di ≤ 10,000)
        d = random.randint(1, 10000)
        # Number of wooden boxes (1 ≤ vi ≤ 10,000)
        v = random.randint(1, 10000)
        warehouses.append((s, d, v))
    
    # Create the input format as a string
    input_data = f"{n}\n"
    for s, d, v in warehouses:
        input_data += f"{s} {d} {v}\n"
    
    return input_data.strip()

# Example usage
for _ in range(3):
    print(tcgen())
    print("---")
```

This function generates random test cases as strings that match the input format specified in the problem statement. Here’s a breakdown of what the function does:

1. Randomly determines the number of warehouses \( n \) (between 1 and 15).
2. Iterates \( n \) times to generate random values for each warehouse:
   - Warehouse number \( s \) (between 1 and 100).
   - Distance from the castle \( d \) (between 1 and 10,000 meters).
   - Number of wooden boxes \( v \) (between 1 and 10,000).
3. Constructs the input data string in the required format.

Each generated test case will be a string that can be directly used as input for the problem. The example usage at the end prints three generated test cases for demonstration.

You can adjust the random ranges and add specific edge cases to ensure comprehensive test coverage.

Extract Arguments

def extract_arguments(fh):
    n = int(fh.readline().strip())
    warehouses = []
    for _ in range(n):
        s, d, v = map(int, fh.readline().strip().split())
        warehouses.append((s, d, v))
    return n, warehouses

# if __name__ == "__main__":
#     input_path = sys.argv[1]
#     with open(input_path, 'r') as fh: 
#         n, warehouses = extract_arguments(fh)
#         f(n, warehouses)