Welcome   HUNAN NORMAL UNIVERSITY ACM/ICPC Judge Online
Home
FAQs
Problem Set
Practices
Online Contests
Major Exercises
OI Special
Judgement
Submit
Online Status
User Ranklist
Users
Register new
Login
Web Links
Hunan Normal University
College of Information Science and Engineering
字符串模式匹配
Time Limit: 500ms, Special Time Limit:1000ms, Memory Limit:32768KB
Total submit users: 76, Accepted users: 67
Problem 10381 : No special judgement
Problem description
  若串 S 中从第pos(S 的下标0≤pos个字符起存在和串 T 相同的子串,则称匹配成功,返回第一个这样的子串在串 S 中的下标,否则返回-1 。请采用KMP算法。

Input
  第一行是测试数据的组数n
每组测试数据占三行,其中第一行是串S(字符串长度不超过500字符),第二行是串T(字符串长度不超过500字符),第三行是一个整数pos,表示串 S 中从第pos个字符起。

Output
  n行,每行输出串T在串S中从第pos个字符起的位置。

Sample Input
2
ababcabcacbababaabcac
abaabcac
0
ababcabcacbab
abcac
0
Sample Output
13
5
Submit   Clarifications   Judge Status  Problems  Ranklist 

HUNAN NORMAL UNIVERSITY ACM/ICPC Judge Online, Version 2010.5.5.final.
Web visits:19355 today,16242346 total, since 2010-05-07