Problem p02962 - Generation 1

Orig Description

Score : 600 points
Problem StatementGiven are two strings s and t consisting of lowercase English letters. Determine if the number of non-negative integers i satisfying the following condition is finite, and find the maximum value of such i if the number is finite.
There exists a non-negative integer j such that the concatenation of i copies of t is a substring of the concatenation of j copies of s.
Notes
A string a is a substring of another string b if and only if there exists an integer x (0 \leq x \leq |b| - |a|) such that, for any y (1 \leq y \leq |a|), a_y = b_{x+y} holds.
We assume that the concatenation of zero copies of any string is the empty string. From the definition above, the empty string is a substring of any string. Thus, for any two strings s and t, i = 0 satisfies the condition in the problem statement.
Constraints
1 \leq |s| \leq 5 \times 10^5
1 \leq |t| \leq 5 \times 10^5
s and t consist of lowercase English letters.
InputInput is given from Standard Input in the following format:
s
t
OutputIf the number of non-negative integers i satisfying the following condition is finite, print the maximum value of such i; if the number is infinite, print -1.
Sample Input 1abcabab
ab
Sample Output 13
The concatenation of three copies of t, ababab, is a substring of the concatenation of two copies of s, abcabababcabab, so i = 3 satisfies the condition.
On the other hand, the concatenation of four copies of t, abababab, is not a substring of the concatenation of any number of copies of s, so i = 4 does not satisfy the condition.
Similarly, any integer greater than 4 does not satisfy the condition, either. Thus, the number of non-negative integers i satisfying the condition is finite, and the maximum value of such i is 3.
Sample Input 2aa
aaaaaaa
Sample Output 2-1
For any non-negative integer i, the concatenation of i copies of t is a substring of the concatenation of 4i copies of s. Thus, there are infinitely many non-negative integers i that satisfy the condition.
Sample Input 3aba
baaab
Sample Output 30
As stated in Notes, i = 0 always satisfies the condition.

Extracted Specification

Canonicalized Input Description:

Two strings, s and t, consisting of lowercase English letters.
The length of each string is between 1 and 500,000.

### Example Input:

```
abcabab
ab
```

### Function Signature:
Write a function f(inputs) that takes in the input.
```python
def f(inputs: Tuple[str, str]):
    '''
    inputs: a tuple containing two strings
    '''
```

Test Case Generator

Certainly! Below is a Python function to generate test cases for the given problem statement. The function ensures that generated test cases adhere to the constraints and provide diverse inputs to thoroughly test the solution.

```python
import random
import string

def generate_random_string(length):
    return ''.join(random.choice(string.ascii_lowercase) for _ in range(length))

def tcgen():
    # Length of strings s and t
    len_s = random.randint(1, 5 * 10**5)
    len_t = random.randint(1, 5 * 10**5)
    
    # Generate random strings s and t of the respective lengths
    s = generate_random_string(len_s)
    t = generate_random_string(len_t)
    
    return s, t

# Example usage
s, t = tcgen()
print(f"s: {s}")
print(f"t: {t}")
```

This generator creates random test cases with the following properties:
- `s` and `t` are randomly generated strings consisting of lowercase English letters.
- The lengths of `s` and `t` are within the given constraints, i.e., between 1 and 500,000.

You can use this function to generate multiple test cases for thorough testing of your solution. Here's how you can generate and print a test case:

```python
for _ in range(5):  # Generate 5 test cases for example
    s, t = tcgen()
    print(f"s: {s}")
    print(f"t: {t}")
    print()
```

Note: If you run this code, it will generate very long strings due to the upper limit constraints (up to 500,000 characters). For practical purposes and readability, you might want to limit the string lengths to smaller values while testing the generator function.

Extract Arguments

def extract_arguments(fh):
    s = fh.readline().strip()
    t = fh.readline().strip()
    return s, t