fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MAX_SIZE = 20;
  5.  
  6. int main() {
  7. int n, m , x, y, mt[MAX_SIZE + 1][MAX_SIZE + 1];
  8. cin >> n >> m >> x >> y;
  9. for (int i = 1; i <= n; ++i) {
  10. for (int j = 1; j <= m; ++j) {
  11. cin >> mt[i][j];
  12. }
  13. }
  14.  
  15. int counterSteps = 0, xSteps = x, ySteps = y;
  16. int pointY = 0, pointX = 0;
  17. // 1 + 3 = 4.
  18. for (int i = 1; i <= n; ++i) {
  19. int a = n, b = 0, copyM = m;
  20. for (int j = 1; j <= m; ++j) {
  21. a = 1 + ySteps; // (1 + 2 = 3), (1 + 1 = 2)
  22. //b = 1 + xSteps;
  23. b = copyM - xSteps;// (6 -3 = 3), ()
  24.  
  25.  
  26.  
  27. if (pointY + a <= n && ySteps > -1) {
  28. pointY += a; // 3
  29. ++counterSteps;// 1
  30. }
  31. if (pointX + b <= n && xSteps > -1 ) {
  32. pointX += b; // 3
  33.  
  34. ++counterSteps; // 2
  35. }
  36. copyM = pointX + 1;
  37. --ySteps;// 1
  38. --xSteps; // 2
  39. }
  40.  
  41. }
  42. cout << counterSteps;
  43.  
  44. return 0;
  45. }
Success #stdin #stdout 0.01s 5320KB
stdin
3 6 
3 2 
1 2 3 4 5 6 
1 2 3 4 5 6 
1 2 3 4 5 6 
stdout
2