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 |
经过多次测试,存在这种数据: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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator