-
Notifications
You must be signed in to change notification settings - Fork 0
/
B.cpp
57 lines (57 loc) · 1.33 KB
/
B.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define MEM 55555
#define sanic ios_base::sync_with_stdio(0)
#define x first
#define y second
#define pf push_front
#define pb push_back
#define all(v) v.begin(), v.end()
#define sz size()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
const ll MOD = 1e9+7;
const ll INF = 2e18+7;
ll mul(ll a, ll b){
return ((a*b)%MOD+MOD)%MOD;
}
ll add(ll a, ll b){
return ((a+b)%MOD+MOD)%MOD;
}
bool cp(pi a, pi b){
return a.x*b.y<b.x*a.y;
}
ll t,n,m;
ll cx[MEM],cy[MEM];
string mp[MEM];
signed main(){
sanic; cin.tie(0); cout.tie(0);
cin >> t;
while(t--){
cin >> n >> m;
for(int i=0; i<n; i++) cin >> mp[i];
ll o1=INF,o2=INF, q1=0, q2=0;
for(int i=0; i<n; i++){
for(int j=0; j<m; j++) {
cx[i] = 0;
cy[j] = 0;
}
}
for(int i=0; i<n; i++){
for(int j=0; j<m; j++) {
cx[i] += (mp[i][j]=='.');
cy[j] += (mp[i][j]=='.');
}
}
ll ans=INF;
for(int i=0; i<n; i++){
for(int j=0; j<m; j++)
ans = min(ans, cx[i]+cy[j]-(mp[i][j]=='.'));
}
cout << ans << '\n';
}
}