import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, std.bitmanip; const long MOD = 10^^9 + 7; void main() { auto N = readln.chomp.to!int; auto A = N.iota.map!(_ => readln.chomp).array; auto tate1 = new bool[](N); auto tate2 = new bool[](N); auto yoko1 = new bool[](N); auto yoko2 = new bool[](N); foreach (i; 0..N) { tate1[i] = iota(N-1).map!(j => A[j][i] == '.').all; tate2[i] = iota(1,N).map!(j => A[j][i] == '.').all; yoko1[i] = iota(N-1).map!(j => A[i][j] == '.').all; yoko2[i] = iota(1,N).map!(j => A[i][j] == '.').all; } int ans = 0; foreach (mask; 0..2^^4) { auto hoge = new bool[4]; foreach (i; 0..4) { hoge[i] = (mask & (1 << i)) != 0; } hoge[0] &= tate1[0]; hoge[1] &= yoko2[0]; hoge[2] &= tate2[N-1]; hoge[3] &= yoko1[N-1]; int tmp = hoge.sum; foreach (i; 1..N-1) { if (hoge[0] && !hoge[2]) { tmp += yoko2[i]; } else if (!hoge[0] && hoge[2]) { tmp += yoko1[i]; } else if (!hoge[0] && !hoge[2]) { tmp += yoko1[i] || yoko2[i]; } } ans = max(ans, tmp); tmp = hoge.sum; foreach (i; 1..N-1) { if (hoge[1] && !hoge[3]) { tmp += tate2[i]; } else if (!hoge[1] && hoge[3]) { tmp += tate1[i]; } else if (!hoge[1] && !hoge[3]) { tmp += tate1[i] || tate2[i]; } } ans = max(ans, tmp); } foreach (mask; 0..2^^4) { auto hoge = new bool[4]; foreach (i; 0..4) { hoge[i] = (mask & (1 << i)) != 0; } hoge[0] &= tate2[0]; hoge[1] &= yoko1[0]; hoge[2] &= tate1[N-1]; hoge[3] &= yoko2[N-1]; int tmp = hoge.sum; foreach (i; 1..N-1) { if (hoge[0] && !hoge[2]) { tmp += yoko2[i]; } else if (!hoge[0] && hoge[2]) { tmp += yoko1[i]; } else if (!hoge[0] && !hoge[2]) { tmp += yoko1[i] || yoko2[i]; } } ans = max(ans, tmp); tmp = hoge.sum; foreach (i; 1..N-1) { if (hoge[1] && !hoge[3]) { tmp += tate2[i]; } else if (!hoge[1] && hoge[3]) { tmp += tate1[i]; } else if (!hoge[1] && !hoge[3]) { tmp += tate1[i] || tate2[i]; } } ans = max(ans, tmp); } }