#P3193. Admission Ticket Safety Check
Admission Ticket Safety Check
Admission Ticket Safety Check
Asen is about to register for the GT exam. His admission ticket number consists of N digits \(X_1, X_2, \dots, X_n\) where \(0 \le X_i \le 9\) for all \(i\). However, he does not want his ticket number to contain a sequence of unlucky digits.
The unlucky sequence is given by \(M\) digits \(A_1, A_2, \dots, A_m\) (where \(0 \le A_i \le 9\)). The ticket number is considered safe if it does not contain any contiguous segment that is exactly equal to the unlucky sequence \(A_1, A_2, \dots, A_m\). Note that both the admission ticket number and the unlucky sequence may have leading zeros.
Your task is to check whether the admission ticket number is safe.
inputFormat
The input consists of three lines:
- The first line contains two integers \(N\) and \(M\), representing the number of digits in the admission ticket number and the unlucky sequence respectively.
- The second line contains a string of \(N\) digits representing the admission ticket number.
- The third line contains a string of \(M\) digits representing the unlucky sequence.
outputFormat
Output a single line: "YES" if the admission ticket number does not contain the unlucky sequence, and "NO" otherwise.
sample
6 3
123456
345
NO