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 |
注意一下这题有个很奇葩的坑点...写并查集的find函数时,不要用递归,,会WA的,,莫名奇妙... int find(int x){ // if(f[x]==x)return x; // return f[x]==find(f[x]); //上面这种形式的会WA,下面两种都可以... // while(x!=f[x]) // x=f[x]; // return x; int k, j, r; r = x; while(r != f[r]) r = f[r]; k = x; while(k != r) { j = f[k]; f[k] = r; k = j; } return r; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator