Problem p02110 - Generation 2

Orig Description

Problem M: Settler
Problem
  There are N vacant lots on a two-dimensional plane, and each is assigned a number from 1 to N. Since all the vacant lots are very small, they can be considered as points. The ith vacant lot exists at (xi,yi).
  Taro decided to select exactly K of these N vacant lots and build buildings on these vacant lots. However, he thought that it would not be interesting to build multiple buildings in too close proximity, so he decided to select vacant lots so that the Euclidean distance between any two vacant lots is always 2 or more.
  Create a program that outputs the combinations of vacant lots that Taro chooses. If there are multiple possible combinations, output the minimum one in lexicographic order. If, however, no matter how K vacant lots are selected, the Euclidean distance between any two vacant lots becomes less than 2, output -1 instead.
Input
Input is given in the following format:
N K
x1 y1
x2 y2
...
xN yN
Constraints
Input satisfies the following conditions:
All input is integers.
2 ≤ K ≤ N ≤ 6,000
1 ≤ xi , yi ≤ 1,000,000    ( 1 ≤ i ≤ N )
 xi mod 2 = floor ( yi ÷ 2 ) mod 2 ( 1 ≤ i ≤ N )
    (where floor ( yi ÷ 2 ) is the value obtained by dividing yi by 2 and truncating the decimal places.)
There are no multiple vacant lots at the same coordinate.
Output
Output the numbers of the vacant lots that Taro selects in ascending order, one per line.
Sample Input 1
3 2
2 1
1 2
1 3
Sample Output 1
1
3
Sample Input 2
4 3
2 1
1 2
1 3
2 4
Sample Output 2
-1
Sample Input 3
5 3
5 7
5 6
6 8
20 20
4 8
Sample Output 3
2
3
4

Extracted Specification

An integer N (2 ≤ N ≤ 6,000), representing some quantity.
An integer K (2 ≤ K ≤ N), representing some quantity.
A list of N tuples (xi, yi), where each tuple contains two integers (1 ≤ xi, yi ≤ 1,000,000) satisfying the condition xi mod 2 = floor(yi ÷ 2) mod 2.

### Example Input:
```
3 2
2 1
1 2
1 3
```

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

Test Case Generator

Certainly! Here's a test case generator for the given problem statement:

```python
import random

def tcgen():
    # Generate N and K within the specified constraints
    N = random.randint(2, 6000)
    K = random.randint(2, N)
    
    vacant_lots = set()
    
    while len(vacant_lots) < N:
        x = random.randint(1, 1000000)
        y = random.randint(1, 1000000)
        
        # Ensure the xi mod 2 = floor(yi / 2) mod 2 condition
        if x % 2 == (y // 2) % 2:
            vacant_lots.add((x, y))
    
    vacant_lots = list(vacant_lots)
    
    # Format the output as required
    result = []
    result.append(f"{N} {K}")
    for lot in vacant_lots:
        result.append(f"{lot[0]} {lot[1]}")
    
    return "\n".join(result)

# Example usage
test_case = tcgen()
print(test_case)
```

This generator ensures that:
1. \(N\) and \(K\) are within the specified constraints.
2. Each coordinate pair \((x_i, y_i)\) satisfies the condition \(x_i \mod 2 = \left\lfloor \frac{y_i}{2} \right\rfloor \mod 2\).
3. No two vacant lots have the same coordinates.

You can use this function to generate random test cases for your problem. Each call to `tcgen()` will produce a new test case formatted as a string, which you can then use to test your solution.

Extract Arguments

def extract_arguments(fh):
    first_line = fh.readline().strip().split()
    N = int(first_line[0])
    K = int(first_line[1])
    coordinates = []
    for _ in range(N):
        x, y = map(int, fh.readline().strip().split())
        coordinates.append((x, y))
    return N, K, coordinates