fork download
  1. #include <bits/stdc++.h>
  2. typedef long long ll;
  3. using namespace std;
  4. #define E '\n'
  5. #define fi "QUANCO.inp"
  6. #define fo "QUANCO.out"
  7. ll dx[5] = {-2,-2,-1,1};
  8. ll dy[5] = {1,-1,-2,-2};
  9. const int N=1e3;
  10. int n , m, fx , fy;
  11. ll dp[N+13][N+13];
  12. bool isValid(ll x,ll y){
  13. return min(x,y) >= 1 && x <= n && y<=m;
  14. }
  15. ll cal(ll tx,ll ty){
  16. while (isValid(tx,ty)){
  17. dp[tx][ty]=0;
  18. for (int k=0 ; k < 4 ;++k ){
  19. ll x = tx+dx[k],y=ty+dy[k];
  20. if (isValid(x,y)) dp[tx][ty]+=dp[x][y];
  21. }
  22. ++tx,--ty;
  23. }
  24. }
  25. int main()
  26. {
  27. ios::sync_with_stdio(0); cin . tie(0); cout . tie(0);
  28. freopen(fi,"r",stdin); freopen(fo,"w",stdout);
  29.  
  30. cin >> n >> m >> fx >> fy;
  31. dp[1][1] = 1;
  32. for (int i=2; i <= m ; ++i) cal(1,i);
  33. for ( int i=2; i <= n ; ++i) cal(i,m);
  34. for (int i=1 ; i<= n ; ++i){
  35. for (int j=1 ; j <= m ; ++j)
  36. cout << dp[i][j] <<" ";
  37. cout << E;
  38. }
  39.  
  40. cout << dp[fx][fy];
  41.  
  42.  
  43. }
  44.  
Success #stdin #stdout 0s 4536KB
stdin
Standard input is empty
stdout
Standard output is empty