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

暴搜老是TLE,加了个诡异的剪枝,居然过了875MS

Posted by xiaoliao at 2012-03-06 22:57:52 on Problem 1035
bool check(char * sa, char * sb)
{
	int an[30], bn[30];
	memset(an, 0, sizeof(an));
	memset(bn, 0, sizeof(bn));
	int i = 0, alen = strlen(sa), blen = strlen(sb);
	for(i = 0; i < alen; i ++) an[sa[i]-'a'] ++;
	for(i = 0; i < blen; i ++) bn[sb[i]-'a'] ++;

	int sum = 0;
	for(i = 0; i < 30; i ++) sum += abs(an[i] - bn[i]);
	
	return (sum <= 2);
}

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