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

 

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值