Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <iostream>
- using namespace std;
- const int _1e6 = 1000000;
- void print(const vector<vector<int> >& lines) {
- cout << endl;
- for (int i = 0; i < lines.size(); i++) {
- for (int j = 0; j < lines[0].size(); j++) {
- if (lines[i][j] == -1) cout << 'X' << " ";
- else cout << lines[i][j] << " ";
- }
- cout << endl;
- }
- cout << endl;
- }
- int main()
- {
- int n, m;
- while ((cin >> n >> m) and n + m > 0) {
- vector<vector<int>> lines(n, vector<int>(m, 0));
- vector<string> input(n);
- for (int i = 0; i < n; i++) cin >> input[i];
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < m; j++) {
- if (input[i][j] == 'X') continue;
- if (i + j == 0) lines[i][j] = 1;
- else if (i == 0) lines[i][j] += lines[i][j-1];
- else if (j == 0) lines[i][j] += lines[i-1][j];
- else {
- lines[i][j] += lines[i][j-1];
- lines[i][j] += lines[i-1][j];
- }
- if (lines[i][j] > _1e6) lines[i][j] = _1e6;
- }
- }
- if (lines[n-1][m-1] >= _1e6) cout << "!!!" << endl;
- else cout << lines[n-1][m-1] << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement