fork download
  1. #include<iostream>
  2. #include<vector>
  3. using namespace std;
  4.  
  5. int sol(int i,int j,vector<vector<char>>v,int h,int w){
  6. if(i>h || j>w){
  7. return 0;
  8. }
  9. if(i==h && j==w){
  10. return 1;
  11. }
  12. if(v[i][j]=='#'){
  13. return 0;
  14. }
  15. return sol(i+1,j,v,h,w) + sol(i,j+1,v,h,w);
  16. }
  17.  
  18. int main(){
  19. int h,w;
  20. cin>>h>>w;
  21. vector<vector<char>>v(h);
  22. char c;
  23. for(int i=0;i<h;i++){
  24. for(int j=0;j<w;j++){
  25. cin>>c;
  26. v[i].push_back(c);
  27. }
  28. }
  29. h--;
  30. w--;
  31. cout<<sol(0,0,v,h,w)<<endl;
  32. }
Success #stdin #stdout 0s 4680KB
stdin
5 5
..#..
.....
#...#
.....
..#..
stdout
24