Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<vector>
- #include<iomanip>
- #include<iostream>
- #include<cmath>
- #include<algorithm>
- using namespace std;
- int main() {
- int x1,y1,x2,y2,x3,y3,x4,y4,kos1,kos2;
- cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
- int p13x = x3 - x1;
- int p13y = y3 - y1;
- int p12x = x2 - x1;
- int p12y = y2 - y1;
- int p14x = x4 - x1;
- int p14y = y4 - y1;
- int p34x = x4 - x3;
- int p34y = y4 - y3;
- int p32x = x2 - x3;
- int p32y = y2 - y3;
- kos1 = (p13x * p12y - p13y * p12x) * (p14x * p12y - p14y * p12x);
- kos2 = ((-p13x) * p34y - (-p13y) * p34x) * (p32x * p34y - p32y * p34x);
- if (x1 < x2) {
- int tmp = x1;
- x1 = x2;
- x2 = tmp;
- }
- if (y1 < y2) {
- int tmp = y1;
- y1 = y2;
- y2 = tmp;
- }
- if (x3 < x4) {
- int tmp = x3;
- x3 = x4;
- x4 = tmp;
- }
- if (y3 < y4) {
- int tmp = y3;
- y3 = y4;
- y4 = tmp;
- }
- if (x1 >= x4 && x3 >= x2 && y1 >= y4 && y3 >= y2 && kos1 <= 0 && kos2 <=0) cout << "YES";
- else cout << "NO";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement