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

实在找不到错了,哪位大侠帮我看看,先谢了!

Posted by jdk2005 at 2006-05-16 12:41:53 on Problem 1975
#include <cstdio>
#include <algorithm>

const int M = 128;
int main(){
	int N, E, Map[M][M], i, j, t, k;
	scanf("%d", &t );
	while( t-- ){
		scanf("%d %d", &N, &E );
		memset( Map, 0, sizeof(Map) );
		int src, des;
		for( i = 0; i < E; i++ ){
			scanf("%d %d", &src, &des );
			Map[src][des] = 1;
		}
		for( i = 1; i <= N; i++ ){
			for( j = 1; j <= N; j++ ){
				for( k = 1; k <= N; k++ ){
					Map[i][j] += Map[i][k]*Map[k][j];
				}
			}
		}
		int count = N;
		for( i = 1; i <= N; i++ ){
			int x = 0;
			for( j = 0; j <= N; j++ ){
				if( Map[i][j] )
					x++;
			}
			int y = 0;
			for( j = 0; j <= N; j++ ){
				if( Map[j][i] )
					y++;
			}
			if( (x+1 <= (N+1)/2 && (N-y) >= (N+1)/2) ){
				count--;
			}
		}
		printf("%d\n", count );
	}
	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