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

重点是input的最后一句...

Posted by 416221843 at 2017-09-21 21:28:59 on Problem 1200
开始以为是输入文件不超过16M...各种hash取模+set各种TLE...
后来发现意思是子串hash后的值不超过16M..开个16M的bool数组就好..hash也简单多了 常规操作
#include<cstdio>
int ha[266], n, i, j, z, ans, te, mm;
bool ch[266], x[16000006];
char ss[688888];
int main()
{
	scanf("%d%*d%s", &n, ss);
	z = ans = mm = 1;
	for (; ss[j]; j++)
		if (!ch[ss[j]])
			ch[ss[j]] = 1, ha[ss[j]] = z++;
	for (; i < n; i++)
		te *= z, te += ha[ss[i]], mm *= z;
	for (x[te] = 1, mm /= z; i < j; i++)
	{
		te %= mm, te *= z, te += ha[ss[i]];
		if (!x[te])
			x[te] = 1, ans++;
	}
	printf("%d\n", n < j ? ans : 0);
}

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