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

Re:不用并查集可不可以做?

Posted by 201293123 at 2013-08-11 13:13:00 on Problem 2524
In Reply To:Re:不用并查集可不可以做? Posted by:380030144 at 2013-03-24 00:12:27
> #include<iostream>
> #include<stdio.h>
> #include<string.h>
> #include<algorithm>
> #include<stdlib.h>
> #include<math.h>
> using namespace std;
> int pre[500500];
> int max(int x,int y)
> {
>     int i=x>y?x:y;
>     return i;
> }
> int main()
> {
>     int i,j=0;
>     int n;
>     long long int m;
>     int x,y;
>     int tmp=0;
>     int sum=0;
>     while(1)
>     {
>         j++;
>         sum=0;
>         scanf("%d",&n);
>         cin>>m;
>         if(n==0)
>         break;
>         memset(pre,0,sizeof(pre));
>     //    printf("%d\n",pre[2]);
>         for(i=0;i<m;i++)
>         {
>         scanf("%d %d",&x,&y);
>         if(x!=y && x!=0 && y!=0)
>         {
>         tmp=max(x,y);
>         pre[tmp]=1;
>         }
>         }
>         for(i=1;i<=n;i++)
>         {
>             if(pre[i]==0)
>             sum++;
>         }
>         printf("Case %d: %d\n\n",j,sum);
>     }
> }

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