Orig Description
Problem B: Grid
Given two coordinates (a1,a2) and (b1,b2) on a two-dimensional grid of size r × c, find the number of shortest paths from the first coordinate to the second coordinate. Moving from one cell to an adjacent cell (one step) costs one unit, and moving from cell (e,c-1) to cell (e,0), or from cell (r-1,f) to cell (0,f), also costs one unit.
Input
The input is given in the following format:
r c a1 a2 b1 b2
The input satisfies the following constraints:
1 ≤ r, c ≤ 1,000
0 ≤ a1, b1 < r
0 ≤ a2, b2 < c
Output
Output the number of shortest paths from the first coordinate to the second coordinate modulo 100,000,007.
Sample Input 1
4 4 0 0 3 3
Sample Output 1
2
Sample Input 2
4 4 0 0 1 1
Sample Output 2
2
Sample Input 3
2 3 0 0 1 2
Sample Output 3
4
Sample Input 4
500 500 0 0 200 200
Sample Output 4
34807775
Extracted Specification
An integer r (1 ≤ r ≤ 1,000), representing some quantity or size.
An integer c (1 ≤ c ≤ 1,000), representing some quantity or size.
An integer a1 (0 ≤ a1 < r), representing some coordinate.
An integer a2 (0 ≤ a2 < c), representing some coordinate.
An integer b1 (0 ≤ b1 < r), representing some coordinate.
An integer b2 (0 ≤ b2 < c), representing some coordinate.
### Example Input:
```
4 4 0 0 3 3
```
### Function Signature:
Write a function f(r, c, a1, a2, b1, b2) that takes in the input.
def f(r: int, c: int, a1: int, a2: int, b1: int, b2: int):
'''
r: an integer
c: an integer
a1: an integer
a2: an integer
b1: an integer
b2: an integer
'''
Test Case Generator
Sure, I can help you with that. Here's a test case generator for the "Grid" problem:
```python
import random
def tcgen():
# Define the maximum values for r and c
max_r = 1000
max_c = 1000
# Randomly select values for r and c within the specified range
r = random.randint(1, max_r)
c = random.randint(1, max_c)
# Randomly select coordinates (a1, a2) and (b1, b2) within the grid
a1 = random.randint(0, r - 1)
a2 = random.randint(0, c - 1)
b1 = random.randint(0, r - 1)
b2 = random.randint(0, c - 1)
return r, c, a1, a2, b1, b2
# Example usage
if __name__ == "__main__":
for _ in range(10): # Generate 10 test cases
print(tcgen())
```
This script randomly generates test cases for the given problem within the specified constraints (1 ≤ r, c ≤ 1,000 and appropriate ranges for the coordinates). Here's how it works:
1. **Grid Size**: It randomly selects the number of rows \(r\) and columns \(c\) within the range [1, 1000].
2. **Coordinates**: It randomly selects the start coordinates \((a1, a2)\) and the end coordinates \((b1, b2)\) ensuring they are within the grid bounds.
3. **Output**: The function returns a tuple with the values \((r, c, a1, a2, b1, b2)\).
To generate multiple test cases, you can call `tcgen()` multiple times as shown in the example usage.
Extract Arguments
def extract_arguments(fh):
r, c, a1, a2, b1, b2 = map(int, fh.readline().strip().split())
return r, c, a1, a2, b1, b2