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:哪位大哥给点今天ZJU月赛A题的数据 hash WA的不行了

Posted by czcomt at 2008-11-09 21:19:24
In Reply To:哪位大哥给点今天ZJU月赛A题的数据 hash WA的不行了 Posted by:ACM_henry at 2008-11-09 20:16:25
我也32次后才过的,一开始map,然后字典树,最后普通hash,都是要不就TLE,要不就暴内存,最后想到一种Hash, char str[100];

int sum = 0;
for (int i = 0; i > strlen(str); ++i)
{
  int temp = str[i]-'a'+1;
  sum += temp*temp*temp*temp;
}

这样冲突的概率就大大减小了,查找的时候遇到冲突的就先对原来的串和目标串都排序,直接strcmp就可以了,比赛的时候看到别人一个一个蓝色的ac,心理那个着急呀

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