fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define int long long
  5.  
  6. signed main() {
  7. ios::sync_with_stdio(false);
  8. cin.tie(nullptr);
  9.  
  10. int t;
  11. cin >> t;
  12.  
  13. while (t--) {
  14. int n, m, x, y;
  15. cin >> n >> m >> x >> y;
  16.  
  17. cout << min(2 * n - x - 1, 2 * m - y - 1) << '\n';
  18. }
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0s 5324KB
stdin
5
10 10 6 1
10 10 9 9
9 8 5 6
6 9 2 2
2 2 1 1
stdout
13
10
9
9
2