Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <vector>
- #include <set>
- #include <algorithm>
- #include <cmath>
- typedef unsigned long long ull;
- typedef long long ll;
- using namespace std;
- int main()
- {
- ios::sync_with_stdio(false);
- cin.tie(0);
- int q;
- cin >> q;
- //q = 100;
- while(q--)
- {
- int n,x,a,b;
- cin >> n >> x >> a >> b;
- int cur = abs(a-b);
- cout << cur + min(n - 1 - cur,x) << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement