Problem:
Score : 400 points

Problem Statement

There is a grid with H horizontal rows and W vertical columns, and there are obstacles on some of the squares.

Snuke is going to choose one of the squares not occupied by an obstacle and place a lamp on it.
The lamp placed on the square will emit straight beams of light in four cardinal directions: up, down, left, and right.
In each direction, the beam will continue traveling until it hits a square occupied by an obstacle or it hits the border of the grid. It will light all the squares on the way, including the square on which the lamp is placed, but not the square occupied by an obstacle.

Snuke wants to maximize the number of squares lighted by the lamp.

You are given H strings S_i (1 \leq i \leq H), each of length W. If the j-th character (1 \leq j \leq W) of S_i is #, there is an obstacle on the square at the i-th row from the top and the j-th column from the left; if that character is ., there is no obstacle on that square.

Find the maximum possible number of squares lighted by the lamp.

Constraints

1 \leq H \leq 2,000

1 \leq W \leq 2,000

S_i is a string of length W consisting of # and ..

. occurs at least once in one of the strings S_i (1 \leq i \leq H).

Input

Input is given from Standard Input in the following format:

H W
S_1
:
S_H

Output

Print the maximum possible number of squares lighted by the lamp.

Sample Input 1

4 6
#..#..
.....#
....#.
#.#...

Sample Output 1

8

If Snuke places the lamp on the square at the second row from the top and the second column from the left, it will light the following squares: the first through fifth squares from the left in the second row, and the first through fourth squares from the top in the second column, for a total of eight squares.

Sample Input 2

8 8
..#...#.
....#...
##......
..###..#
...#..#.
##....#.
#...#...
###.#..#

Sample Output 2

13

Solution in C# (Mono 4.6.2.0) (judge verdict: Time Limit Exceeded)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iH = int.Parse(sS[0]);
            int iW = int.Parse(sS[1]);
            List<List<int>> lstInp = new List<List<int>>();
            for (int i = 0; i < iH; i++)
            {
                string s2 = System.Console.ReadLine().Trim();
                List<int> lstRow = new List<int>();
                for (int j = 0; j < s2.Length; j++)
                {
                    string sOne = s2.Substring(j, 1);
                    switch (sOne)
                    {
                        case "#": lstRow.Add(1); break;
                        case ".": lstRow.Add(0); break;
                    }
                }
                lstInp.Add(lstRow);
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            List<List<int>> lstLeft = new List<List<int>>();
            List<List<int>> lstUppr = new List<List<int>>();
            List<List<int>> lstRigh = new List<List<int>>();
            List<List<int>> lstDown = new List<List<int>>();
            for (int i = 0; i < iH; i++)
            {
                List<int> lstRow1 = new List<int>();
                List<int> lstRow2 = new List<int>();
                List<int> lstRow3 = new List<int>();
                List<int> lstRow4 = new List<int>();
                for (int j = 0; j < iW; j++)
                {
                    lstRow1.Add(0);
                    lstRow2.Add(0);
                    lstRow3.Add(0);
                    lstRow4.Add(0);
                }
                lstLeft.Add(lstRow1);
                lstUppr.Add(lstRow2);
                lstRigh.Add(lstRow3);
                lstDown.Add(lstRow4);
            }
            for (int i = 0; i < lstInp.Count; i++)                  // 行
            {
                int Q = lstInp.Count;
                for (int j = 0; j < lstInp[i].Count; j++)           // 列
                {
                    int R = lstInp[i].Count;
                    if (lstInp[i][j] == 1) { continue; }
                    int iCnt1 = 1;
                    int iCnt2 = 1;
                    int iCnt3 = 1;
                    int iCnt4 = 1;
                    for (int k = j - 1; k >= 0; k--) { if (lstInp[i][k] == 1) { break; } iCnt1 += 1; }
                    for (int k = i - 1; k >= 0; k--) { if (lstInp[k][j] == 1) { break; } iCnt2 += 1; }
                    for (int k = j + 1; k <  R; k++) { if (lstInp[i][k] == 1) { break; } iCnt3 += 1; }
                    for (int k = i + 1; k <  Q; k++) { if (lstInp[k][j] == 1) { break; } iCnt4 += 1; }
                    lstLeft[i][j] = iCnt1;
                    lstUppr[i][j] = iCnt2;
                    lstRigh[i][j] = iCnt3;
                    lstDown[i][j] = iCnt4;
                }
            }

            List<int> lstOut = new List<int>();
            for (int i = 0; i < lstInp.Count; i++)                  // 行
            {
                for (int j = 0; j < lstInp[i].Count; j++)           // 列
                {
                    lstOut.Add(lstLeft[i][j] + lstUppr[i][j] + lstRigh[i][j] + lstDown[i][j] - 3);
                }
            }
            lstOut.Sort(delegate (int mca1, int mca2) { return (int)(mca2 - mca1); });        // 降順

            // 出力
            System.Console.WriteLine("{0}", lstOut[0].ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}