Advertisement
YEZAELP

TOI10: ไปโรงเรียน (Go to School)

Dec 29th, 2020
103
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. using lli = long long;
  6. const lli zero = 0;
  7. lli dp[60][60];
  8. bool dog[60][60];
  9.  
  10. int main(){
  11.  
  12. int m, n;
  13. scanf("%d%d", &m, &n);
  14.  
  15. int d;
  16. scanf("%d", &d);
  17.  
  18. for(int i=1;i<=d;i++){
  19. int I, J;
  20. scanf("%d%d", &J, &I);
  21. dog[I][J] = true;
  22. }
  23.  
  24. for(int i=1;i<=n;i++){
  25. for(int j=1;j<=m;j++){
  26. if(dog[i][j]) continue;
  27. if(i == 1 and j == 1) dp[i][j] = 1;
  28. else if(i == 1) dp[i][j] = dp[i][j-1];
  29. else if(j == 1) dp[i][j] = dp[i-1][j];
  30. else dp[i][j] = dp[i-1][j] + dp[i][j-1];
  31. }
  32. }
  33.  
  34. printf("%lld", dp[n][m]);
  35.  
  36. return 0;
  37. }
  38.  
Advertisement
RAW Paste Data Copied
Advertisement