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

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

 1 /* */
 2 # include 
 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 )
16             cin>>s[i];
17         int cnt = 0;
18         for( int i=0; i )
19         {
20             cnt=0;
21             for( int j=0; j )
22             {
23                 if( s[i][j]=='.' )
24                     cnt++;
25             }
26             r[i] = cnt;
27         }
28         for( int j=0; j )
29         {
30             cnt = 0;
31             for( int i=0; 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 )
40         {
41             for(int j=0; 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

 

转载于:https://www.cnblogs.com/wsy107316/p/11193510.html

你可能感兴趣的:(Educational Codeforces Round 68 (Rated for Div. 2)---B)