#include #include #include using BigInt = boost::multiprecision::cpp_int; using Rational = boost::rational; const BigInt INF = 1LL << 62; struct Point { Point() {} Point(Rational x, Rational y): x(x), y(y) {} Rational x, y; }; Point mid_point(Point lhs, Point rhs) { return Point((lhs.x + rhs.x) / 2, (lhs.y + rhs.y) / 2); } const Rational UNDEF(INF); struct Line { Rational coef; Rational constant; Line() {} Line(Rational coe, Rational con): coef(coe), constant(con) {} Line(Rational coef, Point point): coef(coef), constant(point.y - point.x * coef) {} }; Rational distance(Point lhs, Point rhs) { return (lhs.x - rhs.x) * (lhs.x - rhs.x) + (lhs.y - rhs.y) * (lhs.y - rhs.y); } struct Circle { Point center; Rational radius; Circle(Point p, Rational r): center(p), radius(r) {} }; bool inside(Circle circle, Point point) { return distance(circle.center, point) <= circle.radius; } void solve() { int q; std::cin >> q; std::vector points(3); for (int i = 0; i < 3; i++) { int x, y; std::cin >> x >> y; points[i] = Point(Rational(x), Rational(y)); } std::vector lines(2); for (int i = 0; i < 2; i++) { if (points[i].y == points[i + 1].y) { Point mid = mid_point(points[i], points[i + 1]); lines[i] = Line(UNDEF, mid.x); } else { Rational coef = (points[i + 1].x - points[i].x) / (points[i].y - points[i + 1].y); Point mid = mid_point(points[i], points[i + 1]); lines[i] = Line(coef, mid); } } Point center; if (lines[0].coef == lines[1].coef) { Rational min_dist = UNDEF; for (int i = 0; i < 3; i++) { for (int j = i + 1; j < 3; j++) { Point mid = mid_point(points[i], points[j]); Rational dist(0); for (int k = 0; k < 3; k++) { Rational d = distance(mid, points[k]); if (dist < d) { dist = d; } } if (dist < min_dist) { min_dist = dist; center = mid; } } } } else { if (lines[0].coef == UNDEF || lines[1].coef == UNDEF) { if (lines[0].coef == UNDEF) std::swap(lines[0], lines[1]); center.x = lines[1].constant; center.y = lines[0].coef * center.x + lines[0].constant; } else { center.x = (lines[1].constant - lines[0].constant) / (lines[0].coef - lines[1].coef); center.y = (lines[0].coef * lines[1].constant - lines[0].constant * lines[1].coef) / (lines[0].coef - lines[1].coef); } Rational d = distance(points[0], center); for (int i = 1; i < 3; i++) {} } Rational radius = 0; for (int i = 0; i < 3; i++) { Rational r = distance(center, points[i]); if (radius < r) { radius = r; } } Circle circle(center, radius); while (q--) { int x, y; std::cin >> x >> y; Point p(x, y); std::cout << (inside(circle, p) ? "Yes" : "No") << '\n'; } } int main() { std::cin.tie(0)->sync_with_stdio(0); std::cout << std::fixed << std::setprecision(16); int t = 1; while (t--) solve(); }