#include using namespace std; class Vec { public: double x, y, z; Vec() { x = y = z = 0; } Vec(double x, double y, double z) : x(x), y(y), z(z) {} void rotate(double theta, double phi, double psi) { const double cosT = cos(theta), sinT = sin(theta), cosH = cos(phi), sinH = sin(phi), cosS = cos(psi), sinS = sin(psi); double tx = x, ty = y, tz = z; x = (cosT*cosS - sinT*cosH*sinS) * tx + (-cosT*sinS - sinT*cosH*cosS) * ty + ( sinT*sinH) * tz; y = (sinT*cosS + cosT*cosH*sinS) * tx + (-sinT*sinS + cosT*cosH*cosS) * ty + (-cosT*sinH) * tz; z = (sinH*sinS ) * tx + ( sinH*cosS ) * ty + ( cosH ) * tz; } double norm() const { return x * x + y * y + z * z; } Vec operator-(const Vec& v) const { return Vec(x - v.x, y - v.y, z - v.z); } Vec operator+(const Vec& v) const { return Vec(x + v.x, y + v.y, z + v.z); } }; double dot(const Vec& a, const Vec& b) { return a.x * b.x + a.y * b.y + a.z * b.z; } Vec cross(const Vec& a, const Vec& b) { return Vec(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x); } double getAngle(const Vec& a, const Vec& b) { if (a.norm() * b.norm() < 1e-9) return 0; return acos(dot(a, b) / sqrt(a.norm() * b.norm())); } void rotate(vector& vec, double theta, double phi, double psi) { for (auto& v : vec) v.rotate(theta, phi, psi); } void normalize(vector& v) { Vec v1 = v[0]; Vec v2 = cross(v1, v[1]); double psi = getAngle(Vec(0, 1, 0), Vec(v2.x, v2.y, 0)); double phi = getAngle(Vec(0, 0, 1), Vec(0, sqrt(v2.x * v2.x + v2.y * v2.y), v2.z)); if (v2.x < 0) psi = -psi; v1.rotate(0, phi, psi); double theta = -getAngle(Vec(1, 0, 0), v1); if (v1.y < 0) theta = -theta; rotate(v, theta, phi, psi); } int main() { vector a(4); for (int i = 0; i < 4; ++i) { cin >> a[i].x >> a[i].y >> a[i].z; } vector v(3); for (int i = 0; i < 3; ++i) { v[i] = a[i + 1] - a[0]; } normalize(v); Vec b = v[0], c = v[1], d = v[2]; Vec _c = c - b, _d = d - b; _c.x = -_c.x; _d.x = -_d.x; if (d.y > 0 && c.x * d.y < d.x * c.y && _c.x * _d.y < _d.x * _c.y) { puts("YES"); } else puts("NO"); return 0; }