Posted on 2009-06-02 15:38
Hero 阅读(99)
评论(0) 编辑 收藏 引用 所属分类:
代码如诗--ACM
1 //1215 Accepted 15 336 998 C++
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
5
6 const int oo = -1000000 ;
7
8 int intest ;
9 int inr, inc ;
10 int data[200][200] ;
11
12 int main()
13 {
14 //while( scanf( "%d", &intest ) != EOF )
15 scanf( "%d", &intest ) ;
16 {
17 while( intest -- )
18 {
19 scanf( "%d %d", &inr, &inc ) ;
20 for( int r=1; r<=inr; r++ )
21 {
22 data[r][0] = 0 ;
23 for( int c=1; c<=inc; c++ )
24 {
25 scanf( "%d", &data[r][c] ) ;
26 //找到横行最大
27 if( data[r][c] > data[r][0] )
28 data[r][0] = data[r][c] ;
29 }
30 }//input
31
32 int out = 0 ;
33 //找到纵行最大值
34 for( int c=1; c<=inc; c++ )
35 {
36 data[0][c] = 0 ;
37 for( int r=1; r<=inr; r++ )
38 {
39 if( data[0][c] < data[r][c] )
40 data[0][c] = data[r][c] ;
41 }
42 }
43
44 out = 0 ;
45 for( int r=1; r<=inr; r++ )
46 {
47 for( int c=1; c<=inc; c++ )
48 {
49 if( data[r][c]==data[r][0] && data[r][c]==data[0][c] )
50 out = out + 1 ;
51 }
52 }
53
54 printf( "%d\n", out ) ;
55 }
56 }
57 return 0 ;
58 }