Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
实在找不到错了,哪位大侠帮我看看,先谢了!#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator