| ||||||||||
| 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 | |||||||||
在你的基础上改的!!In Reply To:实在找不到错了,哪位大侠帮我看看,先谢了! Posted by:jdk2005 at 2006-05-16 12:41:53 #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( k = 1; k <= N; k++ ){
for( i = 1; i <= N; i++ ){
for( j = 1; j <= N; j++ ){
Map[i][j] += Map[i][k]*Map[k][j];
if(Map[i][j])
Map[i][j]=1;
}
}
}
int count = 0;
for( i = 1; i <= N; i++ ){
int x = 0;
for( j = 1; j <= N; j++ ){
if( Map[i][j])
x++;
}
int y = 0;
for( j = 1; j <= N; j++ ){
if( Map[j][i])
y++;
}
if( ((x+1) > (N+1)/2) || ((y+1) > (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