func_code_string: #include <bits/stdc++.h>   using namespace std;   struct pkt {     int x, y;   };   int main() {     ios_base::sync_with_stdio(0);     int n, m;     cin >> n >> m;     vector<string> p(n);     for (int i = 0; i < n; ++i) cin >> p[i];     vector<vector<int> > a(n, vector<int>(m, -1));     for (int k = 0; k < n; ++k) {       for (int l = 1; l < m; ++l) {         if (p[k][l - 1] !=  . )           a[k][l] = l - 1;         else           a[k][l] = a[k][l - 1];       }     }     vector<vector<int> > b(n, vector<int>(m, -1));     for (int k = 0; k < n; ++k) {       for (int l = m - 2; l >= 0; --l) {         if (p[k][l + 1] !=  . )           b[k][l] = l + 1;         else           b[k][l] = b[k][l + 1];       }     }     vector<vector<int> > c(n, vector<int>(m, -1));     for (int l = 0; l < m; ++l) {       for (int k = 1; k < n; ++k) {         if (p[k - 1][l] !=  . )           c[k][l] = k - 1;         else           c[k][l] = c[k - 1][l];       }     }     vector<vector<int> > d(n, vector<int>(m, -1));     for (int l = 0; l < m; ++l) {       for (int k = n - 2; k >= 0; --k) {         if (p[k + 1][l] !=  . )           d[k][l] = k + 1;         else           d[k][l] = d[k + 1][l];       }     }     vector<vector<int> > L, P, G, D;     L = a;     P = b;     G = c;     D = d;     int odp = 0, il = 0;     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         if (p[i][j] ==  . ) continue;         int dl = 1;         pkt akt = {i, j};         vector<pkt> z;         while (true) {           pkt nast;           if (p[akt.x][akt.y] ==  L )             nast = {akt.x, L[akt.x][akt.y]};           else {             if (p[akt.x][akt.y] ==  R )               nast = {akt.x, P[akt.x][akt.y]};             else {               if (p[akt.x][akt.y] ==  U )                 nast = {G[akt.x][akt.y], akt.y};               else {                 if (p[akt.x][akt.y] ==  D ) nast = {D[akt.x][akt.y], akt.y};               }             }           }           if (nast.x == -1 || nast.y == -1) break;           ++dl;           pkt le = {akt.x, L[akt.x][akt.y]};           pkt pr = {akt.x, P[akt.x][akt.y]};           if (le.x != -1 && le.y != -1) P[le.x][le.y] = pr.y;           if (pr.x != -1 && pr.y != -1) L[pr.x][pr.y] = le.y;           pkt go = {G[akt.x][akt.y], akt.y};           pkt dol = {D[akt.x][akt.y], akt.y};           if (dol.x != -1 && dol.y != -1) G[dol.x][dol.y] = go.x;           if (go.x != -1 && go.y != -1) D[go.x][go.y] = dol.x;           akt = nast;           z.push_back(le);           z.push_back(pr);           z.push_back(go);           z.push_back(dol);         }         if (dl > odp) {           odp = dl;           il = 1;         } else {           if (dl == odp) ++il;         }         for (int k = 0; k < z.size(); ++k) {           if (z[k].x == -1 || z[k].y == -1) continue;           L[z[k].x][z[k].y] = a[z[k].x][z[k].y];           P[z[k].x][z[k].y] = b[z[k].x][z[k].y];           G[z[k].x][z[k].y] = c[z[k].x][z[k].y];           D[z[k].x][z[k].y] = d[z[k].x][z[k].y];         }       }     }     cout << odp <<     << il;     return 0;   }   