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

3660

Posted by azma at 2009-04-20 16:19:34 on Problem 3660
#include <stdio.h>
const int MAXN=100;
int N, M,i,j,k;
bool D[MAXN][MAXN];
int Res=0;
int main ()
{
	scanf("%d%d", &N, &M);
	for(i=0;i<N;i++) D[i][i]=true;
	int a, b;
	for(i=0;i<M;i++)
	{
		scanf("%d%d", &a, &b);
		a--, b--;
		D[a][b]=true;
	}
	for(k=0;k<N;k++)
	for(i=0;i<N;i++)
		if (D[i][k])
		for(j=0;j<N;j++)
			if (D[k][j])
			D[i][j]=true;

	for(i=0;i<N;i++)
	{
	bool OK= true;
	for(j=0;j<N;j++)
		if (!D[i][j] && !D[j][i])
		{
		OK= false;
		break;
		}
	if (OK)
		Res++;
	}
	printf("%d\n", Res);
	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