-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA_Forked.cpp
More file actions
78 lines (74 loc) · 1.69 KB
/
A_Forked.cpp
File metadata and controls
78 lines (74 loc) · 1.69 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define input for(int &i:v) cin >> i;
void print(const vector<int>& v) {
for (int i : v) {
cout << i << " ";
}
cout << endl;
}
bool isDiagonal(pair<int,int>A, pair<int,int>B)
{
if(A.first == A.second && B.first == B.second) return true;
if(A.first == B.second && B.first == A.second) return true;
if(abs(A.first-A.second) == abs(B.first-B.second)) return true;
if(A.first+A.second == B.first+B.second) return true;
return false;
}
void solve() {
int n,m;
cin >> n;
cin >> m;
int x1, x2, y1, y2;
cin >> x1 >> y1;
cin >> x2 >> y2;
int ans=0;
if((x1==0 && y1==0) && x2&y2==0)
{
if(n==max(x2,y2)/2 || m==max(x2,y2)/2 )
{
if(n==m) ans=1;
else ans=2;
}
}
else if((y2==0 && x2==0) && x1&y1==0)
{
if(n==max(x1,y1)/2 || m==max(x1,y1)/2 )
{
if(n==m) ans=1;
else ans=2;
}
}
else if(isDiagonal({x1,y1},{x2,y2}))
{
cout << "entered\n";
int d1 = (abs(x1-y2) + 1 ) /2;
int d2 = (abs(x2-y1) + 1 ) /2;
cout << d1 << " " << d2;
if(max(n,m)==max(d1,d2) && min(m,n) == min(d1,d2))
{
cout << "entered in\n";
if(n==m)
{
ans = 1;
}
else{
ans = 2;
}
cout << ans << endl;
}
}
cout << ans << endl;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t-- > 0) {
solve();
}
}