Maximal crosses

All submissions for this problem are available.
On the matrix A sized n×n, some cells were marked by crosses (X). For each cell (i,j) (with i – the row index, j – the column index), we define B(i,j) as the maximal number of continuous crosses “going across” the cell (i,j) in the same horizontal, vertical or diagonal; B(i,j)=0 if A(i,j) is empty ( '.' ).
[ Empty cells are marked by '.'] .
Clarification:
Continuous crosses going across cell (i,j) in horizontal direction = x1 + x2  1
where x1 = highest possible x such that
j + x  1<= n and A(i, j ... j + x  1) are all 'X'
and x2 = highest possible x such that
j  x + 1 > 0 and A(i, j  x + 1...j) are all 'X'
Similarily we can extend the definition for vertical and diagonal directions.
Task
Given matrix A as input, calculate matrix B.
Input
 The first line contains the integer n.
 Then follow n lines , each containing n characters. The jth character of the ith line represents the cell (i,j) of the matrix A, with A(i,j)='X' if it contains a cross, or A(i,j)='.' if it is empty.
Output
Output n lines, each contains n integers, the jth integer of the ith line shows the value of B(i,j).
(Each integer on a same line must be separated by exactly one space character)
Example
Input:
10 ..X....XX. XX.X..XX.X .....XX..X .XXX..X.X. .....X..XX ....X....X X.X....XX. .X...X.X.X X.X..X.... ..XXXXX.XX
Output:
0 0 2 0 0 0 0 3 3 0 2 2 0 2 0 0 3 3 0 2 0 0 0 0 0 3 3 0 0 2 0 3 3 3 0 0 3 0 2 0 0 0 0 0 0 3 0 0 2 2 0 0 0 0 3 0 0 0 0 3 4 0 3 0 0 0 0 2 3 0 0 4 0 0 0 3 0 3 0 2 3 0 4 0 0 3 0 0 0 0 0 0 5 5 5 5 5 0 2 2
Limitations
0<n≤1 000
Author:  AnhDQ 
Tester:  anshuman_singh 
Editorial  http://discuss.codechef.com/problems/MAXCROSS 
Tags  anhdq, easy, july10 
Date Added:  4052010 
Time Limit:  0.170455  0.255682 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, SQL, kotlin, PERL6, TEXT, CPP17, SCM chicken, PYP3, CLOJ, R, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 