fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n, m, x, y;
  6. cin >> n >> m >> x >> y;
  7. x--, y--;
  8. int *arr = new int[n * m];
  9. for (int i = 0; i < n; i++) {
  10. for (int j = 0; j < m; j++) {
  11. arr[i * m + j] = (i % 2 == 0 ? i * m + j : i * m + m - j - 1);
  12. }
  13. }
  14. cout << endl << arr[x * m + y];
  15. return 0;
  16. }
Success #stdin #stdout 0s 15232KB
stdin
3 4 3 4
stdout
11