Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <vector>
  3. #include <set>
  4. #include <algorithm>
  5. #include <cmath>
  6. typedef unsigned long long ull;
  7. typedef long long ll;
  8.  
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13. ios::sync_with_stdio(false);
  14. cin.tie(0);
  15. int q;
  16. cin >> q;
  17. //q = 100;
  18. while(q--)
  19. {
  20. int n,x,a,b;
  21. cin >> n >> x >> a >> b;
  22. int cur = abs(a-b);
  23. cout << cur + min(n - 1 - cur,x) << endl;
  24. }
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement