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

有大神知道这题为什么用map会超时么??数组线性查找0ms过。区别就是注释那3行

Posted by illuminator at 2013-03-22 21:12:35 on Problem 1496
char answer[83682][6];
//map<string,int> ans;

void MakeAns()
{
	char word[7];
	int start = 5,i;
	memset(word,'a'-1,sizeof(word));
	word[6] = 'z'+1;
	word[5] = 'a';
	for(int no = 1; no <= 83681;no++)
	{
		i = 0;
		for(int j = start; j < 6; j++) 
			answer[no][i++] = word[j];
		answer[no][i] = 0;
		/*string s(word+start,word+6);
		ans[s] = no;*/
		word[5]++;
		for( i = 5; i > 0 && word[i] >= word[i+1]; i--)
		{
			word[i]--;
			word[i-1]++;
		}

		for( ;i + 1 < 6; i++)
		{
			if( i < start )
			{
				start = i;
			}
			word[i+1] = word[i] + 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