func_code_string: #include <bits/stdc++.h>   using namespace std;   struct chip {     int l;     int r;     int u;     int d;   };   vector<char> a[5005];   vector<chip> link1[5005], link2[5005];   int n, m, kq, res;   void nhap() {     ios_base::sync_with_stdio(0);     cin >> n >> m;     char x;     for (int i = 1; i <= n; ++i) a[i].push_back(   );     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j) {         cin >> x;         a[i].push_back(x);       }     for (int i = 1; i <= n; ++i) a[i].push_back(   );     for (int i = 0; i <= m + 1; ++i) {       a[0].push_back(   );       a[n + 1].push_back(   );     }     for (int i = 0; i <= n + 1; ++i)       for (int j = 0; j <= m + 1; ++j) {         chip x;         x.l = 0;         x.r = 0;         x.u = 0;         x.d = 0;         link1[i].push_back(x);         link2[i].push_back(x);       }   }   void prep() {     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j)         if (a[i][j] !=  . ) {           int l = j - 1, r = j + 1, u = i - 1, d = i + 1;           while (a[i][l] ==  .  && l > 0) --l;           while (a[i][r] ==  .  && r <= m) ++r;           while (a[u][j] ==  .  && u > 0) --u;           while (a[d][j] ==  .  && d <= n) ++d;           link1[i][j].l = l;           link1[i][j].r = r;           link1[i][j].u = u;           link1[i][j].d = d;         }   }   void xl(int x, int y) {     int dem = 0;     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j) link2[i][j] = link1[i][j];     while (a[x][y] !=  .  && x > 0 && x <= n && y > 0 && y <= m) {       ++dem;       int l = link2[x][y].l, r = link2[x][y].r, u = link2[x][y].u,           d = link2[x][y].d;       link2[x][l].r = r;       link2[x][r].l = l;       link2[u][y].d = d;       link2[d][y].u = u;       if (a[x][y] ==  L )         y = l;       else if (a[x][y] ==  R )         y = r;       else if (a[x][y] ==  U )         x = u;       else if (a[x][y] ==  D )         x = d;     }     kq = max(kq, dem);   }   void xl1(int x, int y) {     int dem = 0;     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j) link2[i][j] = link1[i][j];     while (a[x][y] !=  .  && x > 0 && x <= n && y > 0 && y <= m) {       ++dem;       int l = link2[x][y].l, r = link2[x][y].r, u = link2[x][y].u,           d = link2[x][y].d;       link2[x][l].r = r;       link2[x][r].l = l;       link2[u][y].d = d;       link2[d][y].u = u;       if (a[x][y] ==  L )         y = l;       else if (a[x][y] ==  R )         y = r;       else if (a[x][y] ==  U )         x = u;       else if (a[x][y] ==  D )         x = d;     }     if (dem == kq) ++res;   }   int main() {     nhap();     prep();     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j)         if (a[i][j] !=  . ) xl(i, j);     cout << kq <<    ;     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j)         if (a[i][j] !=  . ) xl1(i, j);     cout << res;     return 0;   }   