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

强烈BS自己,居然把相同时的gang加了个s,wa N次 In the same gang, 无s!

Posted by 2008022118 at 2010-01-10 09:31:28 on Problem 1703 and last updated at 2010-01-10 09:37:09
具体做法并查集。我有两个数组,fa[],和to[],
输入D a b,fa[]初始化为-1,to[a]=b,to[b]=a;
当a,b第一次出现fa[a]=a,fa[b]=a,to[a]=b,to[b]=a;
当a,b有一个已经出现过了(假设a),就把b和to[Find(a)]合并;
。。。
输入A a b
i=Find(a),j=Find(b);
if (i!=-1&&j!=-1&&(Find(to[i])==j||Find(to[j])==i))
                printf("In different gangs.\n");
             else if (i==j&&i!=-1)
                  printf("In the same gang.\n");
             else printf("Not sure yet.\n");

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