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

Why mine code is WA?I wonder........(Sample had passed).Search for superior!

Posted by VitaminC at 2005-08-04 21:59:31 on Problem 2524
//pku.2524.problem 
#include<iostream>
using namespace std;
int main()
{
	int n, m, kind, a, b, i=1, j;
	while(1)
	{
		cin>>n>>m;
		if(n==0 && m==0)
			break;
		int flag1[60000]={0}, flag2[60000]={0};
		kind=0;
		while(m--)
		{
			scanf("%d %d", &a, &b);
			if(flag2[a]==0 && flag2[b]==0)
			{	
				flag1[a]=0;
				flag1[b]=1;
				flag2[a]=1;
				flag2[b]=1;
			}
			else
				if(flag2[a]==1 && flag2[b]==0)
				{
					flag1[b]=1;
					flag2[b]=1;
				}
				else
					if(flag2[b]==1 && flag2[a]==0)
					{
						flag1[a]=1;
						flag2[a]=1;
					}
					
		}
		for(j=1; j<=n; j++)
		{
			if(flag1[j]==0)
				kind++;
		}
		printf("Case %d: %d\n", i, kind);
		i++;
	}
	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