#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<utility>
#include<algorithm>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define For(i,x,y) for(int i=((int)x);i<=((int)y);i++)
#define Dep(i,y,x) for(int i=((int)y);i>=((int)x);i--)
#define Rep(i,x) for (int y,i=head[x];i;i=E[i].nxt)
using namespace std;
const int mod=1000000007;
const int inf=1000000009;
typedef double db;
typedef long long ll;
typedef vector<int> VI;
typedef unsigned int uint;
typedef pair<int,int> pii;
int rd() {
char c=getchar(); int t=0,f=1;
while (!isdigit(c)) f=(c=='-')?-1:1,c=getchar();
while (isdigit(c)) t=t*10+c-48,c=getchar(); return t*f;
}
void wt(int x) {
if (x<0) putchar('-'),wt(-x);
else { if (x>9) wt(x/10); putchar(x%10+48); }
}
const int N=515;
char s[N][N]; int n,Min=inf,l,ok[N],flag,Ans;
int main() {
n=rd();
For (i,1,n) {
scanf("%s",s[i]+1);
For (j,1,n) if (s[i][j]=='#') ok[j]=1;
}
For (i,1,n) {
l=0;
For (j,1,n) if (s[i][j]=='#') l++;
if (l) Min=min(Min,n-l+1-ok[i]);
}
if (Min==inf) return puts("-1"),0;
Ans+=Min;
For (j,1,n) {
flag=0;
For (i,1,n) if (s[i][j]!='#')
{ flag=1; break; }
Ans+=flag;
}
printf("%d\n",Ans);
return 0;
}
./Main.cpp: In function ‘int main()’:
./Main.cpp:47:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%s",s[i]+1);
^