#define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define MT make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< >(b,vector(c,d)) #define vvv(a,b,c,d,e) vector > >(b,vv(a,c,d,e)) using ll = long long; using pii = pair; using vi = vector; using vll = vector; int N, ans; bool a[75][75], b[75][75], c[75][75]; vector yk, tt; int counts() { memcpy(b, a, sizeof(a)); int res = 0; each(p, tt) { bool ok = true; rep(i, N - 1) { if (b[p.first+i][p.second]) { ok = false; break; } } if (ok) { rep(i, N - 1) { b[p.first + i][p.second] = true; } res++; } } RT res; } int put(int i, int j, int di, int dj) { int ni = i + di*(N - 1); int nj = j + dj*(N - 1); if (ni > N || nj > N)RT 0; rep(k, N - 1) { int ii = i + di*k; int jj = j + dj*k; if (a[ii][jj])RT 0; } rep(k, N - 1) { int ii = i + di*k; int jj = j + dj*k; a[ii][jj] = true; } RT 1; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); cin >> N; vector S(N); rep(i, N) { cin >> S[i]; rep(j, N)if (S[i][j] == '#')c[i][j] = true; } rep(ITER, 2) { // すべて左に置く { memcpy(a, c, sizeof a); int val = 0; rep(i, N) { // i行目に置く val += put(i, 0, 0, 1); } // 縦はおけるだけ置く rep(i, 2)rep(j, N)val += put(i, j, 1, 0); smax(ans, val); } // すべて右に置く { memcpy(a, c, sizeof a); int val = 0; rep(i, N) { // i行目に置く val += put(i, 1, 0, 1); } // 縦はおけるだけ置く rep(i, 2)rep(j, N)val += put(i, j, 1, 0); smax(ans, val); } vector sp{ {0, 0}, { 0,1 }, { N - 1,0 }, { N - 1,1 }}; // 上または下だけに置く rep(S, 1 >> 4) { memcpy(a, c, sizeof a); int val = 0; rep(i,4)if(S>>i&1)val += put(sp[i].first, sp[i].second, 0, 1); // 縦はおけるだけ置く rep(i, 2)rep(j, N)val += put(i, j, 1, 0); smax(ans, val); } // 貪欲に置く { memcpy(a, c, sizeof a); int val = 0; // 横におけるだけ rep(i, N)rep(j, N) { val += put(i, j, 0, 1); } rep(i, N)rep(j, N) { val += put(i, j, 1, 0); } smax(ans, val); } // 輪 { memcpy(a, c, sizeof a); int val = 0; val += put(0, 0, 0, 1); val += put(0, N - 1, 1, 0); val += put(N - 1, 1, 0, 1); val += put(1, 0, 1, 0); smax(ans, val); } // 縦、横交換 rep(i, N)rep(j, N)a[i][j] = c[j][i]; memcpy(c, a, sizeof a); } cout << ans << endl; }