forked from Aniket965/Hello-world
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Some snake
32 lines (32 loc) · 1.09 KB
/
Some snake
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
#include <bits/stdc++.h>
using namespace std;
int main()
{
int T; cin >> T;
while(T--)
{
int x11, x12, x21, x22, y11, y12, y21, y22, slope1, slope2;
bool flag = 0;
cin>>x11>>y11>>x12>>y12>>x21>>y21>>x22>>y22;
slope1 = (x11==x12)?1:0;
slope2 = (x21==x22)?1:0;
if(slope1!=slope2)
{
if(slope1 == 0 && ((x11 == x21 || x12 == x21) && (y11 == y21 || y11 == y22)))
flag = 1;
else if (slope2 == 0 && ((x21 == x11 || x22 == x11 ) && (y21 == y11 || y21 == y12)))
flag = 1;
else if ( (slope1 == 0 && (x21 == x22 && y21 == y22) && y11 == y21 && (x21>=min(x11,x12) && x21<=max(x12,x11)) ) ||
(slope2 == 0 && (x11 == x12 && y11 == y12) && y11 == y21 && (x11>=min(x21,x22) && x11<=max(x21,x22)) ) )
flag = 1;
}
else if(slope1 == 1 && x11==x22 && max(y21, y22)>=min(y11, y12) && min(y21, y22)<=max(y11, y12))
flag = 1;
else if(y11==y22 && max(x21, x22)>=min(x11, x12) && min(x21, x22)<=max(x11, x12))
flag = 1;
if (flag)
cout <<"yes\n";
else
cout <<"no\n";
}
}