func_code_string: #include <bits/stdc++.h>   using namespace std;   struct p {     int L, R, U, D;   } point[5005], pos[5005];   string g[5005];   void DEL(int x) {     pos[pos[x].D].U = pos[x].U;     pos[pos[x].U].D = pos[x].D;     pos[pos[x].R].L = pos[x].L;     pos[pos[x].L].R = pos[x].R;   }   int main() {     int m, n, i, j, l, sx, sy;     scanf( %d%d , &m, &n);     for (i = 0; i < m; i++) cin >> g[i];     n = g[0].size();     for (i = 0; i < m; i++) {       for (j = 0; j < n; j++) {         if (g[i][j] !=  . ) {           for (l = i - 1; l >= 0; l--)             if (g[l][j] !=  . ) break;           if (l < 0)             point[i * n + j].U = -1;           else             point[i * n + j].U = l * n + j;           for (l = i + 1; l < m; l++)             if (g[l][j] !=  . ) break;           if (l >= m)             point[i * n + j].D = -1;           else             point[i * n + j].D = l * n + j;           for (l = j - 1; l >= 0; l--)             if (g[i][l] !=  . ) break;           if (l < 0)             point[i * n + j].L = -1;           else             point[i * n + j].L = i * n + l;           for (l = j + 1; l < n; l++)             if (g[i][l] !=  . ) break;           if (l >= n)             point[i * n + j].R = -1;           else             point[i * n + j].R = i * n + l;         }       }     }     int r1 = 0, r2 = 0, cnt, t, x, y;     for (sx = 0; sx < m; sx++) {       for (sy = 0; sy < n; sy++)         if (g[sx][sy] !=  . ) {           for (i = 0; i < m; i++) {             for (j = 0; j < n; j++) {               pos[i * n + j] = point[i * n + j];             }           }           if (g[sx][sy] ==  D )             t = pos[sx * n + sy].D;           else if (g[sx][sy] ==  U )             t = pos[sx * n + sy].U;           else if (g[sx][sy] ==  R )             t = pos[sx * n + sy].R;           else if (g[sx][sy] ==  L )             t = pos[sx * n + sy].L;           DEL(sx * n + sy);           cnt = 1;           while (t != -1) {             cnt++;             x = t / n;             y = t % n;             DEL(t);             if (g[x][y] ==  D )               t = pos[t].D;             else if (g[x][y] ==  U )               t = pos[t].U;             else if (g[x][y] ==  R )               t = pos[t].R;             else if (g[x][y] ==  L )               t = pos[t].L;           }           if (cnt > r1) {             r1 = cnt;             r2 = 1;           } else if (cnt == r1) {             r2++;           }         }     }     printf( %d %d n , r1, r2);     return 0;   }   