fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. ios::sync_with_stdio(0);
  6. cin.tie(0);
  7.  
  8. int n;
  9. cin >> n;
  10.  
  11. int a[n+1][n+1];
  12. int dp[n+1][n+1] = {0};
  13.  
  14. for(int i = 1; i <= n; i++)
  15. for(int j = 1; j <= n; j++)
  16. cin >> a[i][j];
  17.  
  18. if(a[1][1] == 0)
  19. dp[1][1] = 1;
  20.  
  21. for(int i = 1; i <= n; i++) {
  22. for(int j = 1; j <= n; j++) {
  23. if(a[i][j] == 1) continue;
  24.  
  25. if(i > 1) dp[i][j] = (dp[i][j] + dp[i-1][j]);
  26. if(j > 1) dp[i][j] = (dp[i][j] + dp[i][j-1]);
  27. }
  28. }
  29.  
  30. cout << dp[n][n] % 1000000;
  31.  
  32. return 0;
  33. }
Success #stdin #stdout 0.01s 5320KB
stdin
5
0 1 1 0 0
0 0 1 0 1
0 0 0 0 0
1 0 1 0 0
0 0 0 0 0
stdout
8