NAJPF - Pattern Find

Your task is so simple given a string and a pattern. You find the pattern on the given string. If found print how many time found the pattern and their index. Otherwise print ‘Not Found’

Input:          

The input   line consists of a number T (1 ≤ T ≤ 50) test cases.

For each case given two string number  A,B. the string and the pattern  1 ≤|A|, |B| ≤10^6

All character will be lower case Latin character.  And |  | is the length of string.

Output:

For each case print the number  (found pattern from the given string) next line there position And Otherwise print 'Not Found' without quota.
There will a blank line between two cases.

Sample:

Input

Output

3
ababab ab
aaaaa bbb
aafafaasf aaf

3
1 3 5

Not Found

1
1

 

 

Hints:

Here all index is 1 base.


Added by:Najmuzzaman
Date:2014-10-23
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 GOSU

hide comments
2021-01-20 12:58:10
Getting tle with rabin karp help!!
2021-01-03 10:50:58
KMP giving TLE in python3 wtf
2020-12-28 12:06:44
"print the number first" got me WA 3 times wtf?

Last edit: 2020-12-28 12:07:02
2020-12-22 18:58:32
AC in One Go !!
2020-12-02 09:17:22
This article on cp-algorithms is nice: https://cp-algorithms.com/string/prefix-function.html
2020-11-09 08:58:31
AC in first try!
2020-10-06 16:09:29
did with rabin karp
2020-10-02 13:28:10
I am using Rabin Karp algo I'm not able to figure out why I am getting a segmentation fault :( Please help!!
2020-09-24 09:25:10
I am getting segmentation fault that is SIGSEGV error can anyone tell why this error cam by using Rabin Karp Algo
2020-08-30 15:14:47
too weak test case.
what a shit problem to test the algorithm
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.