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

超时的请注意--

Posted by LeibnizZhang at 2016-08-02 16:38:14 on Problem 3164
	int j=i;
			do
			{
				visit[j]=true;
				j=pre[j];
			}while(!visit[j]);
			if (j==1) continue;//从根节点出发--到i之间无环。
			i=j;/*这里是i=j,,,写成j=i就超时--- 如果有环时j不是回到i了吗?? 
			原来是从i想上找---循环可能没有i---如:3——4---5----4:pre[3]=4--pre[4]=5---pre[5]=4;
			这样的话--如果下面的循环还是从i开始--但是判断结果是就j!=i--永远会不到3的位置--就会 Time Limit Exceeded*/
			do
			{
				ans+=map[pre[j]][j];
				j=pre[j];
			}while (j!=i);

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