Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- double mod(int x){
- if (x<0){
- x=-x;
- }
- return x;
- }
- int sign(int x){
- if (x>0){
- return 1;
- }
- if (x==0){
- return 0;
- }
- return -1;
- }
- struct Point{
- int x;
- int y;
- };
- Point draw_vector(Point p, Point q){
- return {q.x-p.x, q.y-p.y};
- }
- int cross_product(Point p, Point q){
- return p.x*q.x+p.y*q.y;
- }
- int dot_product(Point p, Point q){
- return p.x*q.y-p.y*q.x;
- }
- int main(){
- Point a, o, b, p;
- cin>>a.x>>a.y>>o.x>>o.y>>b.x>>b.y>>p.x>>p.y;
- if (dot_product(draw_vector(o, a), draw_vector(o, p))==0){
- if (cross_product(draw_vector(o, p), draw_vector(o, a))>=0){
- cout<<"YES"<<"\n";
- return 0;
- }
- cout<<"NO"<<"\n";
- return 0;
- }
- if (dot_product(draw_vector(o, b), draw_vector(o, p))==0){
- if (cross_product(draw_vector(o, p), draw_vector(o, b))>=0){
- cout<<"YES"<<"\n";
- return 0;
- }
- cout<<"NO"<<"\n";
- return 0;
- }
- if (sign(dot_product(draw_vector(o, a), draw_vector(o, p)))==sign(dot_product(draw_vector(o, a), draw_vector(o, b)))){
- if (sign(dot_product(draw_vector(o, b), draw_vector(o, p)))==sign(dot_product(draw_vector(o, b), draw_vector(o, a)))){
- cout<<"YES"<<"\n";
- return 0;
- }
- }
- cout<<"NO"<<"\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement