fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int m,n;
  4. int cnt =0;
  5. vector<vector<int>> mtx;
  6. void bt(int x,int y){
  7. if(x == m - 1 || y == n - 1) {
  8. cnt++;
  9. return;
  10. }
  11.  
  12. if(x <= m - 2 && y <= n - 2){
  13. bt(x + 1,y);
  14. bt(x, y + 1);
  15. }
  16. else return;
  17.  
  18. }
  19. int main(){
  20. int t;
  21. cin >> t;
  22. while(t--){
  23. cin >> m >> n;
  24. mtx.resize(m,vector<int>(n));
  25. for(int i = 0 ; i < m;i++){
  26. for(int j = 0; j < n;j++){
  27. cin >> mtx[i][j];
  28. }
  29. }
  30. bt(0,0);
  31. cout << cnt << endl;
  32. mtx.clear();
  33. cnt =0;
  34. }
  35.  
  36.  
  37. }
  38.  
Success #stdin #stdout 0.01s 5288KB
stdin
2
2  3
1  2  3
4  5  6
2  2
1  2
3  4
stdout
0
0