結果
| 問題 |
No.2602 Real Collider
|
| コンテスト | |
| ユーザー |
nono00
|
| 提出日時 | 2024-01-12 22:33:44 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,454 bytes |
| コンパイル時間 | 3,210 ms |
| コンパイル使用メモリ | 250,592 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-27 23:12:52 |
| 合計ジャッジ時間 | 8,243 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 58 WA * 20 |
ソースコード
#include <bits/stdc++.h>
struct Point {
Point(long double x = 0, long double y = 0): x(x), y(y) {}
long double x, y;
};
Point mid_point(Point lhs, Point rhs) {
return Point((lhs.x + rhs.x) / 2, (lhs.y + rhs.y) / 2);
}
constexpr long double EPS = 1e-8;
constexpr long double UNDEF = 1e60;
bool eq(long double lhs, long double rhs) {
return std::abs(lhs - rhs) < EPS;
}
struct Line {
long double coef;
long double constant;
Line() {}
Line(long double coe, long double con): coef(coe), constant(con) {}
Line(long double coef, Point point): coef(coef), constant(point.y - point.x * coef) {}
};
bool eq(Line lhs, Line rhs) {
return eq(lhs.coef, rhs.coef) && eq(lhs.constant, rhs.constant);
}
bool lt(long double lhs, long double rhs) {
return eq(lhs, rhs) || lhs + EPS < rhs;
}
long double distance(Point lhs, Point rhs) {
return std::hypot<long double>(lhs.x - rhs.x, lhs.y - rhs.y);
}
struct Circle {
Point center;
long double radius;
Circle(Point p, long double r): center(p), radius(r) {}
};
bool inside(Circle circle, Point point) {
return lt(distance(circle.center, point), circle.radius);
}
void solve() {
int q;
std::cin >> q;
std::vector<Point> points(3);
for (int i = 0; i < 3; i++) {
std::cin >> points[i].x >> points[i].y;
}
std::vector<Line> lines(2);
for (int i = 0; i < 2; i++) {
if (eq(points[i].y, points[i + 1].y)) {
Point mid = mid_point(points[i], points[i + 1]);
lines[i] = Line(UNDEF, mid.x);
} else {
long double 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 (eq(lines[0].coef, lines[1].coef)) {
long double min_dist = 1e18;
for (int i = 0; i < 3; i++) {
for (int j = i + 1; j < 3; j++) {
Point mid = mid_point(points[i], points[j]);
long double dist = 0;
for (int k = 0; k < 3; k++) {
dist = std::max(dist, distance(mid, points[k]));
}
if (dist < min_dist) {
min_dist = dist;
center = mid;
}
}
}
} else {
if (eq(lines[0].coef, UNDEF) || eq(lines[1].coef, UNDEF)) {
if (eq(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);
}
long double d = distance(points[0], center);
for (int i = 1; i < 3; i++) {}
}
long double radius = 0;
for (int i = 0; i < 3; i++) {
radius = std::max(radius, distance(center, points[i]));
}
Circle circle(center, radius);
while (q--) {
Point p;
std::cin >> p.x >> p.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();
}
nono00