Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

2774这题标程有错

Posted by zm198740 at 2007-11-11 16:41:37 on Problem 2774
有个兄弟在论坛里贴了这么一组数据:
zzzab
cdefabcdef
正确答案是2,而不是6。但是6的答案AC了,2的反而错了,为什么呢?

这题一般的做法是后缀数组
把两个串拼在一起,求各后缀的最长公共前缀,具体见xzl的论文
有一个细节要处理,以这个数据为例,应该在两个串的拼接位置加1个不属于'a'~'z'的一个字符,因此正确的拼好的串应该是:zzzab$cdefabcdef
这样在后缀ab$cdefabcdef和abcdef中找到最长公共前缀长度为2

而标程显然没有做这样的处理,得到的错误的拼好的串是zzzabcdefabcdef
这样在后缀abcdefabcdef和abcdef中找到最长公共前缀长度为6

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator