All submissions for this problem are available.You are given a String $S$ of length $N$ consisting of only $0$ and $1$. There are $K$ no of queries where each query consists of one character $'L'$ or $'R '$ and one integer $P$. Your task is to rotate the String in left (for input L) or in right (for input R) direction for $P$ times and form a new string by taking the last character of the rotated String after the end of the rotation of each query. Now check whether the newly generated String from the queries is a substring of the given original String or not. If it is a substring print YES, else print NO. ###Input: The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. The first line of each test case contains two space-separated integers $N$ and $K$. The first line of each test case contains the String $S$. The next $K$ lines contain the character $L$ or $R$ and a space integer $P$. ###Output: For each test case, print YES if the resultant string is a substring of the given string, otherwise print NO. ###Constraints: - $1 \leq T \leq 10$ - $1 \leq N \leq 10^5$ - $1 \leq K \leq N$ - $1 \leq P \leq N$ ###Subtasks: - 30 points : $1 \leq N \leq 100$ - 70 points : $Original$ $Constraints$ ###Sample Input: 2 4 3 1001 L 2 R 3 R 1 8 3 10101101 L 2 L 3 R 4 ###Sample Output: NO YES ###Explanation: For test case 1: After 1st rotation (L 2), String is 0110 After 2nd rotation (R 3), String is 1100 After 3rd rotation (R 1), String is 0110 So, the resultant string after taking the last characters is 000 which is not a substring of 1001.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, NODEJS, PERL, FORT, JS, SQL, PERL6, PYP3, R|
Fetching successful submissions
If you are still having problems, see a sample solution here.