You may have ever heard about Caesar's code, which adds a constant value to each character then modulo every character by 26 as a "rotation" operation.
CiCaesar = Ci+k mod 26, for i=1,...,length(C)
Now, given a string S, you have to find out whether S was encoded from a segment of the following texts or not.
Of course, the encoding method should be Caesar's code.
There are several cases in the input file.
The first line of the input file contains an integer T<=20 specifying the number of cases.
Every case starts with an integer N, followed by a string S with length 1<=N<=100000, composed by characters A-Z.
Then there's an integer 1<=M<=100, denoting the number of texts we want to examine.
The next M lines contain the description of M texts, expressed in the same format as S.
For each text, output '1' if S is contained in an encoding of this text, otherwise output '0'.
1 3 ACB 2 5 ABDCE 6 FACDEB
1 0
Migrated from old NTUJ.
pP
No. | Testdata Range | Score |
---|