Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #include <vector>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. const int _1e6 = 1000000;
  7.  
  8. void print(const vector<vector<int> >& lines) {
  9. cout << endl;
  10. for (int i = 0; i < lines.size(); i++) {
  11. for (int j = 0; j < lines[0].size(); j++) {
  12. if (lines[i][j] == -1) cout << 'X' << " ";
  13. else cout << lines[i][j] << " ";
  14. }
  15. cout << endl;
  16. }
  17. cout << endl;
  18. }
  19.  
  20. int main()
  21. {
  22. int n, m;
  23.  
  24. while ((cin >> n >> m) and n + m > 0) {
  25. vector<vector<int>> lines(n, vector<int>(m, 0));
  26. vector<string> input(n);
  27.  
  28. for (int i = 0; i < n; i++) cin >> input[i];
  29.  
  30. for (int i = 0; i < n; i++) {
  31. for (int j = 0; j < m; j++) {
  32. if (input[i][j] == 'X') continue;
  33. if (i + j == 0) lines[i][j] = 1;
  34. else if (i == 0) lines[i][j] += lines[i][j-1];
  35. else if (j == 0) lines[i][j] += lines[i-1][j];
  36. else {
  37. lines[i][j] += lines[i][j-1];
  38. lines[i][j] += lines[i-1][j];
  39. }
  40. if (lines[i][j] > _1e6) lines[i][j] = _1e6;
  41. }
  42. }
  43.  
  44. if (lines[n-1][m-1] >= _1e6) cout << "!!!" << endl;
  45. else cout << lines[n-1][m-1] << endl;
  46. }
  47.  
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement