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:为什么总是超时?

Posted by zhjianfeng at 2006-03-24 08:23:11 on Problem 1159
In Reply To:为什么总是超时? Posted by:Gump at 2005-12-03 14:28:57
> # include< iostream.h >
> short dp[5010][5010];   // 保存每一步的状态
> char s[5010];
> void main()
> {
> 	int len,i,j;
> 	cin>> len;
> 	cin>> s;
> 
> 	for( i= 0; i< len; i++ )
> 		for( j=1; j+i <= len; j++ )
> 			if( s[j-1] == s[i+j-1] )
> 				dp[j][i+j]= dp[j+1][i+j-1];
> 			else
> 				dp[j][i+j]= ( dp[j][i+j-1] < dp[j+1][i+j] ? dp[j][i+j-1]:d[j+1][i+j])+1;
> 
> 	cout<<dp[1][len]<<endl;
> 
> 
> }

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