#include<iostream> usingnamespace std; int n, m, ans = 2147483647; //最大值 bool a[15][15], t[15]; //定义 a 和 t
voiddfs(int pos){ //这里的注释就不用我多说了吧 if (pos > n) { bool w[15] = {}; for (int i = 1; i <= n; i++) { if (!t[i]) continue; for (int j = 1; j <= m; j++) { w[j] |= a[i][j]; } } int sum = 0, c = 0; for (int i = 1; i <= m; i++) { sum += w[i]; } for (int i = 1; i <= n; i++) { c += t[i]; } if (sum == m && c < ans) { ans = c; } return; } for (int i = 0; i <= 1; i++) { t[pos] = i; dfs(pos + 1); } }
intmain(){ cin >> n >> m; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { char c; cin >> c; a[i][j] = (c == 'o'); } } dfs(1); cout << ans; return0; }