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

换成G++AC !!! AC!!!! AC!!! C++格式提交居然WA!

Posted by 1615925431 at 2017-04-01 11:07:23 on Problem 1611
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int father[30020];
int fd(int x)
{
    if(father[x]==x)
    {
        return x;
    }
    fd(father[x]);
}
int flag;
int main()
{
    int n,m,p1,p2;
    while(~scanf("%d%d",&n,&m))
    {
        flag=0;
        for(int i=0;i<=n;i++)
        {
            father[i]=i;
        }
        if(n==0&&m==0)
        {
            break;
        }
        int g,a,b;
        while(m--)
        {
            scanf("%d%d",&g,&a);
            while(--g)
            {
                scanf("%d",&b);
                p1=fd(a);
                p2=fd(b);
                father[p1]=p2;
            }
        }
        int c;
        int ans=0;
        c=fd(father[0]);
        for(int i=0;i<=n;i++)
        {
            if(fd(father[i])==c)
            {
                ans++;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

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