-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1806a.cpp
More file actions
40 lines (34 loc) · 724 Bytes
/
1806a.cpp
File metadata and controls
40 lines (34 loc) · 724 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <bits/stdc++.h>
using namespace std;
bool checkParity(int a,int b){
if(a%2==0 && b%2 == 0 || a%2==1 && b%2 == 1){
return true;
}else{
return false;
}
}
int main() {
int t;
cin >> t;
while (t--) {
long long a,b,c,d;
cin >> a >> b >> c >> d;
int ans = 0;
if(b > d){
ans = -1;
}else if(a == c && b == d){
ans = 0;
}else{
int y_move = d-b;
a = a + y_move;
if(a < c){
ans = -1;
}else{
int x_move = abs(c-a);
ans = x_move + y_move;
}
}
cout << ans << "\n";
}
return 0;
}