|
Time |
Memory |
Case 1 |
1 sec |
32 MB |
Case 2 |
1 sec |
32 MB |
Case 3 |
1 sec |
32 MB |
Case 4 |
1 sec |
32 MB |
Case 5 |
1 sec |
32 MB |
Case 6 |
1 sec |
32 MB |
Case 7 |
1 sec |
32 MB |
Case 8 |
1 sec |
32 MB |
Case 9 |
1 sec |
32 MB |
Case 10 |
1 sec |
32 MB |
Description
You are given a source string $S$, an integer $k$, and a target string $T$.
Determine whether there exists a contiguous substring of S with length $k$ whose characters can be rearranged to form $T$, you can left some characters unused.
If such a window exists, print YES
; otherwise, print NO
.
Input
- Line 1: the source string $S$
- Line 2: the integer $k$
- Line 3: the target string $T$
Constraints
- $1 \leq \lvert S \rvert, \lvert T \rvert \leq 2 \times 10^5$
- $0 \leq k \leq 2 \times 10^5$
Subtask
For testcases 1~5:
- $1 \leq \lvert S \rvert, \lvert T \rvert \leq 1000$
- $0 \leq k \leq 1000$
For testcases 6~10:
- No additional constraints.
Output
Print YES
if there exists a contiguous substring of $S$ with length $k$ whose characters can be rearranged to form $T$ (possibly with extra unused characters in the window).
Otherwise, print NO
.