| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
超时的请注意-- 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator