Language: C++

#include <stdio.h>
#include <queue>
using namespace std;


int main()
{
    queue<int> x,y,longth;
    int n,memlongth,ans;
    int dx1[9] = {-1,-1,-1,0,0,0,1,1,1},dy1[9] = {-1,0,1,-1,0,1,-1,0,1},dx2[3] = {1,0,1},dx2[3] = {0,1,1};
    while(1)
    {
        char field[1010][1010] = {0},N;
        scanf("%d",&n);
        if(n == 0)return 0;
        scanf("%c",&N);
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < n + 1; j++)
            {
                scanf("%c",&field[j][i]);
                if(field[j][i] == '*')
                {
                    x.push(j);
                    y.push(i);
                    longth.push(0);
                }
            }
        }
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < n + 1; j++)
            {
                if(field[j][i] == '.' && (i == 0 || i == n - 1 || j == 0 || j == n - 1))
                {
                    field[j][i] = '1';
                    x.push(j);
                    y.push(i);
                    longth.push(1);
                }
            }
        }
        while(x.size())
        {
            for(int i = 0; i < 9; i++)
            {
                if(0 <= x.front() + dx1[i] && x.front() + dx1[i] < n &&
                   0 <= y.front() + dy1[i] && y.front() + dy1[i] < n &&
                   field[x.front() + dx1[i]][y.front() + dy1[i]] == '.')
                {
                    field[x.front() + dx1[i]][y.front() + dy1[i]] = longth.front() + 1 + '0';
                    x.push(x.front() + dx1[i]);
                    y.push(y.front() + dy1[i]);
                    longth.push(longth.front() + 1);
                    memlongth = longth.front() + 1;
                    /*for(int i = 0; i < n; i++)
                    {
                        for(int j = 0; j < n + 1; j++)
                        {
                            printf("%c",field[j][i]);
                        }
                    }
                    printf("\n");*/
                }
            }
            x.pop();
            y.pop();
            longth.pop();
        }
        ans = longth * 2 - 1;
        for(int i = 0; i < n - 1; i++)
        {
            for(int j = 0; j < n - 1; j++)
            {
                if(field[j][i] - '0' == memlongth)
                {
                    for(int k = 0; k < 3; k++)
                    {
                        if(field[j + dx2[k]][i + dy2[k]] = memlongth);
                        else bleak;
                        if(k == 2)ans = longth * 2;
                    }
                }
            }
        }
        printf("%d\n",ans);
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:90: error: redeclaration of 'int dx2 [3]'
   10 |     int dx1[9] = {-1,-1,-1,0,0,0,1,1,1},dy1[9] = {-1,0,1,-1,0,1,-1,0,1},dx2[3] = {1,0,1},dx2[3] = {0,1,1};
      |                                                                                          ^~~
a.cc:10:73: note: 'int dx2 [3]' previously declared here
   10 |     int dx1[9] = {-1,-1,-1,0,0,0,1,1,1},dy1[9] = {-1,0,1,-1,0,1,-1,0,1},dx2[3] = {1,0,1},dx2[3] = {0,1,1};
      |                                                                         ^~~
a.cc:70:22: error: no match for 'operator*' (operand types are 'std::queue<int>' and 'int')
   70 |         ans = longth * 2 - 1;
      |               ~~~~~~ ^ ~
      |               |        |
      |               |        int
      |               std::queue<int>
a.cc:79:50: error: 'dy2' was not declared in this scope; did you mean 'dx2'?
   79 |                         if(field[j + dx2[k]][i + dy2[k]] = memlongth);
      |                                                  ^~~
      |                                                  dx2
a.cc:80:30: error: 'bleak' was not declared in this scope
   80 |                         else bleak;
      |                              ^~~~~
a.cc:81:48: error: no match for 'operator*' (operand types are 'std::queue<int>' and 'int')
   81 |                         if(k == 2)ans = longth * 2;
      |                                         ~~~~~~ ^ ~
      |                                         |        |
      |                                         |        int
      |                                         std::queue<int>