Naxocist

Go to School

Apr 26th, 2022
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define ll long long
  6.  
  7. using pi = pair<int, int>;
  8.  
  9. const int N = 55;
  10.  
  11. int r, c;
  12.  
  13. ll memo[N][N];
  14.  
  15. bool d[N][N];
  16.  
  17. int main() {
  18.  
  19.     ios::sync_with_stdio(false); cin.tie(nullptr);
  20.    
  21.     cin >> c >> r;
  22.  
  23.     int t; cin >> t;
  24.  
  25.     while(t--) {
  26.         int y, x; cin >> y >> x;
  27.         d[x][y] = 1;
  28.     }
  29.  
  30.     memo[1][0] = 1;
  31.  
  32.     for(int i=1; i<=r; ++i){
  33.         for(int j=1; j<=c; ++j){
  34.             if(!d[i][j]) memo[i][j] = memo[i-1][j] + memo[i][j-1];
  35.         }
  36.     }
  37.  
  38.     cout << memo[r][c];
  39.  
  40.     return 0;
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment