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

Re:贡献了几次WA和TLE总结

Posted by acmor at 2013-06-14 17:40:23 on Problem 1035
In Reply To:贡献了几次WA和TLE总结 Posted by:acmor at 2013-06-14 17:38:18
> 看其他discussion,暴力还是能解决的,不过没有尝试,用的trie。
> 1、尽量别用stl的string,来回copy还是比较费时间,替换和插入这种操作还是用char操作效率高。
> 2、剪枝1:记录所有输入字符串的length,在查找前对比length,对于替换操作,如果对应长度的字符串在trie中不存在直接忽略,对于插入操作,如果len+1长度的字符串在trie中不存在则忽略,对于删除操作,len-1长度的字符串在trie中不存在也忽略。
> 3、剪枝2:查找原串的时候记录不匹配字符的index,这样index+1之后的替换、插入、删除都可以忽略了,当然前提是正向匹配

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