#include // std::string #include // std::cout #include #include using namespace std; int n; int m; vector a; int sol = -1; void Rec(int row, int col, int path) { if ((row == n || col == m)) { // solution if (path > sol) sol = path; return; } if (a[row][col] == '&') { // solution if (path > sol) sol = path; return; } // go down Rec(row + 1, col, path + 1); // go right Rec(row, col + 1, path + 1); } int main() { string tmp; getline(cin, tmp); stringstream ss(tmp); ss >> n; ss >> m; for(int i=0; i 0) if (c[i-1][j] + 1 > c[i][j] && a[i - 1][j] != '&') c[i][j] = c[i-1][j]+1; if (j > 0) if (c[i][j-1] + 1 > c[i][j] && a[i][j-1] != '&') c[i][j] = c[i][j-1]+1; if (c[i][j] > sol) sol=c[i][j]; } //Rec(0,0,0); cout << sol + 1; return 0; } /* 4 4 ..&. ..&. ..&. ..&. */