#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define forr(x,arr) for(auto&& x:arr) #define _overload3(_1,_2,_3,name,...) name #define _rep2(i,n) _rep3(i,0,n) #define _rep3(i,a,b) for(int i=int(a);i=int(a);i--) #define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__) #define all(x) (x).begin(),(x).end() #define bit(n) (1LL<<(n)) #define sz(x) ((int)(x).size()) #define TEN(n) ((ll)(1e##n)) #define fst first #define snd second string DBG_DLM(int &i){return(i++==0?"":", ");} #define DBG_B(exp){int i=0;os<<"{";{exp;}os<<"}";return os;} templateostream&operator<<(ostream&os,vectorv); templateostream&operator<<(ostream&os,setv); templateostream&operator<<(ostream&os,queueq); templateostream&operator<<(ostream&os,priority_queueq); templateostream&operator<<(ostream&os,pairp); templateostream&operator<<(ostream&os,mapmp); templateostream&operator<<(ostream&os,unordered_mapmp); templatevoid DBG(ostream&os,TPL t){} templatevoid DBG(ostream&os,TPL t){os<<(I==0?"":", ")<(t);DBG(os,t);} templatevoid DBG(ostream&os,pairp,string delim){os<<"("<ostream&operator<<(ostream&os,tuplet){os<<"(";DBG<0,tuple,Ts...>(os,t);os<<")";return os;} templateostream&operator<<(ostream&os,pairp){DBG(os,p,", ");return os;} templateostream&operator<<(ostream&os,vectorv){DBG_B(forr(t,v){os<ostream&operator<<(ostream&os,sets){DBG_B(forr(t,s){os<ostream&operator<<(ostream&os,queueq){DBG_B(for(;q.size();q.pop()){os<ostream&operator<<(ostream&os,priority_queueq){DBG_B(for(;q.size();q.pop()){os<ostream&operator<<(ostream&os,mapm){DBG_B(forr(p,m){os<");});} templateostream&operator<<(ostream&os,unordered_mapm){DBG_B(forr(p,m){os<");});} #define DBG_OVERLOAD(_1,_2,_3,_4,_5,_6,macro_name,...)macro_name #define DBG_LINE(){char s[99];sprintf(s,"line:%3d | ",__LINE__);cerr<;using pll=pair;using pil=pair;using pli=pair; using vs=vector;using vvs=vector;using vvvs=vector; using vb=vector;using vvb=vector;using vvvb=vector; using vi=vector;using vvi=vector;using vvvi=vector; using vl=vector;using vvl=vector;using vvvl=vector; using vd=vector;using vvd=vector;using vvvd=vector; using vpii=vector;using vvpii=vector;using vvvpii=vector; templatebool amax(A&a,const B&b){return b>a?a=b,1:0;} templatebool amin(A&a,const B&b){return b>l;return l;} string rs(){string s;cin>>s;return s;} namespace geom3d { using T = double; struct P3D { T x, y, z; P3D() : x(0), y(0), z(0) {}; P3D(T x, T y, T z) : x(x), y(y), z(z) {}; P3D operator+(const P3D &b) const { const P3D &a = *this; P3D ret(a.x + b.x, a.y + b.y, a.z + b.z); return ret; } P3D operator-(const P3D &b) const { const P3D &a = *this; P3D ret(a.x - b.x, a.y - b.y, a.z - b.z); return ret; } P3D operator-() const { const P3D &a = *this; P3D ret(-a.x, -a.y, -a.z); return ret; } P3D operator*(const T &d) const { const P3D &a = *this; const P3D ret(a.x * d, a.y * d, a.z * d); return ret; } P3D operator/(const T &d) const { const P3D &a = *this; const P3D ret(a.x / d, a.y / d, a.z / d); return ret; } /** * 内積 */ T operator*(const P3D &b) const { const P3D &a = *this; return a.x * b.x + a.y * b.y + a.z * b.z; } /** * 外積 */ P3D operator^(const P3D &b) const { const P3D &a = *this; P3D ret(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x); return ret; } }; struct Plane { P3D h; T d; Plane(const P3D &i, const P3D &j, const P3D &k) { P3D ij = i - j; P3D ik = i - k; h = ij ^ ik; d = -h.x * i.x - h.y * i.y - h.z * i.z; } }; /** * 平面との距離 */ T distanceP(const P3D &p, const Plane &pl) { const P3D &h = pl.h; T si = fabs(h.x * p.x + h.y * p.y + h.z * p.z + pl.d); T bo = sqrt(h.x * h.x + h.y * h.y + h.z * h.z); return si / bo; } /** * 平面との距離 */ T distanceP(const P3D &p, const P3D &a, const P3D &b, const P3D &c) { return distanceP(p, Plane(a, b, c)); } } using namespace geom3d; bool sol(P3D a, P3D b, P3D c, P3D d) { Plane plane(a, b, c); double dp = distanceP(d, plane); P3D hou = plane.h; double hlen = sqrt(hou.x * hou.x + hou.y * hou.y + hou.z * hou.z); out(hlen); hou.x /= hlen; hou.y /= hlen; hou.z /= hlen; out(hou.x, hou.y, hou.z); d.x -= hou.x * dp; d.y -= hou.y * dp; d.z -= hou.z * dp; out(d.x, d.y, d.z); P3D ab = b - a; P3D bc = c - b; P3D ca = a - c; P3D ad = d - a; P3D bd = d - b; P3D cd = d - c; P3D abd = ab ^ bd; P3D bcd = bc ^ cd; P3D cad = ca ^ ad; double dot1 = abd * bcd; double dot2 = abd * cad; return dot1 > 0 && dot2 > 0; } void Main() { P3D a(ri(), ri(), ri()); P3D b(ri(), ri(), ri()); P3D c(ri(), ri(), ri()); P3D d(ri(), ri(), ri()); if (sol(a, b, c, d) || sol(a, c, b, d)) { cout << "YES" << endl; } else { cout << "NO" << endl; } } signed main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }