#include using namespace std; #include using namespace atcoder; //高速化 struct ponjuice{ponjuice(){cin.tie(0);ios::sync_with_stdio(0);cout<using vc = vector; templateusing vvc = vc>; templateusing vvvc = vvc>; using vi = vc; using vvi = vvc; using vvvi = vvvc; using vl = vc; using vvl = vvc; using vvvl = vvvc; using pi = pair; using pl = pair; using ull = unsigned ll; templateusing priq = priority_queue; templateusing priqg = priority_queue, greater>; // for文 #define overload4(a, b, c, d, e, ...) e #define rep1(n) for(ll i = 0; i < n; i++) #define rep2(i, n) for(ll i = 0; i < n; i++) #define rep3(i, a, b) for(ll i = a; i < b; i++) #define rep4(i, a, b, step) for(ll i = a; i < b; i+= step) #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #define per1(n) for(ll i = n-1; i >= 0; i--) #define per2(i, n) for(ll i = n-1; i >= 0; i--) #define per3(i, a, b) for(ll i = b-1; i >= a; i--) #define per4(i, a, b, step) for(ll i = b-1; i >= a; i-= step) #define per(...) overload4(__VA_ARGS__, per4, per3, per2, per1)(__VA_ARGS__) #define fore1(a) for(auto&& i : a) #define fore2(i,a) for(auto&& i : a) #define fore3(x,y,a) for(auto&& [x, y] : a) #define fore4(x,y,z,a) for(auto&& [x, y, z] : a) #define fore(...) overload4(__VA_ARGS__, fore4, fore3, fore2, fore1)(__VA_ARGS__) //関数 #define mp make_pair #define mt make_tuple #define a first #define b second #define pb emplace_back #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define si(x) (ll)(x).size() templateinline bool chmax(S& a, T b){return a < b && ( a = b , true);} templateinline bool chmin(S& a, T b){return a > b && ( a = b , true);} templatevoid uniq(vc&a){sort(all(a));a.erase(unique(all(a)),a.end());} templatevc operator++(vc&v,signed){auto res = v;fore(e,v)e++;return res;} templatevc operator--(vc&v,signed){auto res = v;fore(e,v)e--;return res;} templatevc operator++(vc&v){fore(e,v)e++;return v;} templatevc operator--(vc&v){fore(e,v)e--;return v;} //入出力(operator) templateistream&operator>>(istream&is,static_modint&a){ll v;is>>v;a=v;return is;} istream&operator>>(istream&is,modint&a){ll v;cin>>v;a=v;return is;} templateistream&operator>>(istream&is,pair&a){is>>a.a>>a.b;return is;} templateistream&operator>>(istream&is,vc&a){fore(e,a)is>>e;return is;} templateostream&operator<<(ostream&os,static_modinta){return os<ostream&operator<<(ostream&os,pair&a){return os<ostream&operator<<(ostream&os,set&a){fore(it,a){os<ostream&operator<<(ostream&os,multiset&a){fore(it,a){os<ostream&operator<<(ostream&os,map&a){fore(x,y,a){os<ostream&operator<<(ostream&os,unordered_set&a){fore(it,a){os<ostream&operator<<(ostream&os,unordered_map&a){fore(x,y,a){os<ostream&operator<<(ostream&os,vc&a){fore(e,a)os<ostream&operator<<(ostream&os,vvc&a){fore(e,a)os<>a;return a;} vl readvl(ll n){vl a(n);cin>>a;return a;} vvi readg(ll n,ll m,bool bidirected=true){vvi g(n);rep(i,m){ll a,b;cin>>a>>b;a--;b--;g[a].pb(b);if(bidirected)g[b].pb(a);}return g;} vvcreadgc(ll n,ll m,bool bidirected=true){vvc g(n);rep(i,m){ll a,b,c;cin>>a>>b>>c;a--;b--;g[a].pb(b,c);if(bidirected)g[b].pb(a,c);}return g;} vvi readt(ll n,bool bidirected=true){return readg(n,n-1,bidirected);} vvc readtc(ll n,bool bidirected=true){return readgc(n,n-1,bidirected);} inline void yes(){cout << "Yes\n";} inline void no(){cout << "No\n";} inline void yesno(bool y = true){if(y)yes();else no();} inline void print(){cout<inline void print(T a){cout<inline void print(T a,Ts ...b){cout<>t; while(t--)solve(); } #include #include #include using namespace std; using Real = ll; using Point = complex; const Real EPS = 1e-8, PI = acos(-1); // 多分いらない入出力 istream &operator>>(istream &is, Point& p) { Real a, b; is >> a >> b; p = Point(a, b); return is; } ostream &operator<<(ostream &os, Point p) { return os << fixed << p.real() << " " << p.imag(); } ////////////////// Point operator*(Point p, Real d) { return Point(real(p) * d, imag(p) * d); } inline bool equal(Real a, Real b){ return fabs(a - b) < EPS; } Point unit(Point a) { return a / abs(a); } Point normal(Point a) { return a * Point(0, 1); } Point normalUnit(Point a) { return unit(normal(a)); } Real dot(Point a, Point b){ return a.real() * b.real() + a.imag() * b.imag(); } Real cross(Point a, Point b){ return (a.real() * b.imag() - a.imag() * b.real()); } Point rotate(Point a, double theta){ return Point(cos(theta) * a.real() - sin(theta) * a.imag(), sin(theta) * a.real() + cos(theta) * a.imag()); } Real radianToDegree(Real r) { return r * 180 / PI; } Real degreeToRadian(Real d) { return d * PI / 180; } struct Line{ Point a,b; Line() = default; Line(Point A, Point B) : a(A), b(B) {} // ax + by = c Line(Real A, Real B, Real C){ if(equal(A, 0)) a = Point(0, C / B), b = Point(1, C / B); else if(equal(B, 0)) b = Point(C / A, 0), b = Point(C / A, 1); else a = Point(0, C / B), b = Point(C / A, 0); } friend ostream &operator<<(ostream &os, Line &p) { return os << p.a << " to " << p.b; } friend istream &operator>>(istream &is, Line &a) { return is >> a.a >> a.b; } }; using Segment = Line; struct Circle{ Point p; Real r; Circle() = default; Circle(Point p, Real r) : p(p), r(r) {} }; // 点pから線lに垂線を下ろした時の交点 Point projection(Line l, Point p){ Real t = dot(p - l.a, l.b - l.a) / norm(l.b - l.a); return l.a + (l.b - l.a) * t; } int ccw(Point a, Point b, Point c){ b -= a; c -= a; // 反時計回り if(cross(b, c) > EPS) return 1; // 時計回り if(cross(b, c) < -EPS) return -1; // c-a-bの順番で点がある if(dot(b, c) < 0) return -2; // a-b-cの順番で点がある if(norm(b) < norm(c)) return 2; // a-b の間にcがある return 0; } bool isParallel(Line a, Line b){ return equal(cross(a.b - a.a, b.b - b.a), 0); } bool isOrthogonal(Line a, Line b){ return equal(dot(a.b - a.a, b.b - b.a), 0); } bool IsIntersect(Segment s, Segment t){ return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 && ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0; } Point crossPoint(Line s, Line t){ Real d1 = cross(s.b - s.a, t.b - t.a); Real d2 = cross(s.b - s.a, s.b - t.a); if(equal(d1, 0) && equal(d2, 0)){ if( ccw(t.a, t.b, s.a) == 0) return s.a; if( ccw(t.a, t.b, s.b) == 0) return s.b; if( ccw(s.a, s.b, t.a) == 0) return t.a; if( ccw(s.a, s.b, t.b) == 0) return t.b; } return t.a + (t.b - t.a) * (d2 / d1); } Real distance(Segment l, Point p){ if(dot(l.b - l.a, p - l.a) < EPS) return abs(p - l.a); if(dot(l.a - l.b, p - l.b) < EPS) return abs(p - l.b); return abs(cross(l.b - l.a, p - l.a)) / abs(l.b - l.a); } Real distance(Segment s, Segment t){ if(IsIntersect(s,t)) return 0; Real res = distance(s,t.a); res = min(res, distance(s, t.b)); res = min(res, distance(t, s.a)); res = min(res, distance(t, s.b)); return res; } Real area(vector& p){ Real res = 0; int n = p.size(); for(int i = 0; i < n - 1; i++){ res += cross(p[i], p[i+1]); } res += cross(p[n-1],p[0]); return res * 0.5; } bool isConvex(vector& p){ bool res = true; int n = p.size(); for(int i = 0; i < n; i++) { if(cross(p[(i+1)%n]-p[i], p[(i+2)%n] - p[(i+1)%n]) < -EPS){ res = false; } } return res; } void solve(){ Point a,b,c,d; cin >> a >> b >> c >> d; Line q(a,c),w(b,d); if(isParallel(q,w) || norm(a-b) < norm(b-d)){ no(); return; } if(q.b != w.b && distance(q,w) == 0){ no(); return; } yesno(abs(c.real() - d.real()) * abs(a.imag() - b.imag()) == abs(c.imag() - d.imag()) * abs(a.real() - b.real()) ); }