Last active
April 24, 2017 18:28
-
-
Save izanbf1803/6b0fcc94a1fa5fbcb23ed5ee53ba6db0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment