Educational Codeforces Round 68 (Rated for Div. 2)---B

http://codeforces.com/contest/1194/problem/B

 1 /* */
 2 # include <bits/stdc++.h>
 3 using namespace std;
 4  
 5 int r[50005], c[50005];
 6 string s[50005];
 7  
 8 int main()
 9 {
10     int n, m, q;
11     scanf("%d", &q);
12     while( q-- )
13     {
14         scanf("%d %d", &n, &m);
15         for(int i=0; i<n; i++ )
16             cin>>s[i];
17         int cnt = 0;
18         for( int i=0; i<n; i++ )
19         {
20             cnt=0;
21             for( int j=0; j<m; j++ )
22             {
23                 if( s[i][j]=='.' )
24                     cnt++;
25             }
26             r[i] = cnt;
27         }
28         for( int j=0; j<m; j++ )
29         {
30             cnt = 0;
31             for( int i=0; i<n; i++ )
32             {
33                 if( s[i][j]=='.' )
34                     cnt++;
35             }
36             c[j] = cnt;
37         }
38         int ans = 50005;
39         for( int i=0; i<n; i++ )
40         {
41             for(int j=0; j<m; j++ )
42             {
43                 int temp = r[i]+c[j];
44                 if( s[i][j]=='.' )
45                     temp--;
46                 ans = min(ans, temp);
47             }
48         }
49         printf("%d\n", ans);
50     }
51     return 0;
52 }
53  
View Code

 

posted @ 2019-07-16 10:55  swsyya  阅读(122)  评论(0编辑  收藏  举报

回到顶部