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 Moon_1st at 2011-05-23 21:28:15 on Problem 1703 and last updated at 2011-05-23 21:37:45
2 2
D 1 2
D 2 1
此时这种写法会MLE——递归层数太多:
fa = getf(a);
fb = getf(b);
if(c == 'D')
{
   f[fb] = a;
   dis[fb] = 1^dis[b];
}
而这种写法则会导致WA:
fa = getf(a);
fb = getf(b);
if(c=='D' && fa!=fb)
{
   f[fb] = a;
   dis[fb] = 1^dis[b];
}
这可能是因为后台测试数据中有矛盾数据,这样写才可以过:
if(c == 'D')
{
   f[fb] = fa;
   dis[fb] = 1^dis[b]^dis[a];
}
总感觉这题的描述有点小bug,部分细节没描述出来,但数据中却出现了。

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