Problem p02187 - Generation 3

Orig Description

F: Partial String Decomposition
Problem
Given two strings S and T, and an integer k. Determine if S can be constructed by concatenating continuous substrings of T that have a length of at least k.
Here, a continuous substring s[l, r] = s_l s_{l+1} ... s_r (1 \leq l \leq r \leq n) of a string s = s_1 s_2 ... s_n refers to a string that can be obtained by extracting characters from position l to position r of s, and its length is r - l + 1.
Input Format
S
T
k
Constraints
Both S and T are composed of lowercase alphabets.
1 \leq |S|, |T| \leq 2\times 10^5
1 \leq k \leq |T|
Output Format
If S can be constructed, output Yes; otherwise, output No.
Sample Input 1
abracadabra
cadabra
4
Sample Output 1
Yes
By concatenating the continuous substrings abra and cadabra of T (both of which have a length of at least 4), we can construct abracadabra, which is equal to S.
Sample Input 2
abcd
zcba
1
Sample Output 2
No
Sample Input 3
abc
zcba
1
Sample Output 3
Yes
Sample Input 4
abcdefg
abcddefg
4
Sample Output 4
No

Extracted Specification

Canonicalized Input Description:

Two strings S and T, both composed of lowercase alphabets.
An integer k, where 1 ≤ k ≤ |T|.

### Example Input:

```
abracadabra
cadabra
4
```

### Function Signature:
Write a function f(S, T, k) that takes in the input. 
```python
def f(S: str, T: str, k: int):
    ''' 
    S: a string 
    T: a string 
    k: an integer 
    '''
```

Test Case Generator

Certainly! Based on the problem statement for "Partial String Decomposition," here is a test case generator written in Python:

```python
import random
import string

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

def tcgen():
    # Generate random lengths for S and T within the given constraints.
    len_S = random.randint(1, 2 * 10**5)
    len_T = random.randint(1, 2 * 10**5)
    
    # Generate random strings S and T of the given lengths.
    S = generate_string(len_S)
    T = generate_string(len_T)
    
    # Generate a random integer k within the constraint 1 ≤ k ≤ |T|
    k = random.randint(1, len_T)
    
    return S, T, k

# Example of generating a test case
S, T, k = tcgen()
print("S:", S)
print("T:", T)
print("k:", k)
```

This test case generator creates random strings `S` and `T` and a random integer `k` as per the constraints given in the problem statement. It ensures that:
- `S` and `T` are composed of lowercase alphabets.
- The lengths of `S` and `T` are within the range [1, 200,000].
- The integer `k` is within the range [1, len(T)].

To use this test case generator, simply run the code, and it will print out a randomly generated test case for you.

Extract Arguments

def extract_arguments(fh):
    S = fh.readline().strip()
    T = fh.readline().strip()
    k = int(fh.readline().strip())
    return S, T, k