#B3829. Substring Partitioning Challenge
Substring Partitioning Challenge
Substring Partitioning Challenge
Given a string \(s\) consisting only of uppercase letters, lowercase letters, and digits, and an integer \(k\), determine whether it is possible to split \(s\) into at least \(k\) contiguous substrings \(s_1, s_2, \dots, s_t\) (with \(t \ge k\)) such that for every index \(i\) with \(2 \le i \le t\), the substring \(s_i\) is a substring of the concatenation \(s_1s_2\dots s_{i-1}\).
A string \(a\) is said to be a substring of a string \(b\) if \(a\) can be obtained by deleting some (possibly empty) prefix and some (possibly empty) suffix from \(b\). Note that the substrings in the partition must be contiguous segments of \(s\>.
Output YES if such a partition exists; otherwise, output NO.
inputFormat
The input consists of two lines:
- The first line contains the string \(s\) (only digits and letters).
- The second line contains an integer \(k\) representing the minimum number of substrings required.
outputFormat
Output a single line containing either YES or NO (without quotes) indicating whether \(s\) can be partitioned into at least \(k\) substrings satisfying the given condition.
sample
aaa
3
YES