結果
問題 | No.2602 Real Collider |
ユーザー | nono00 |
提出日時 | 2024-01-12 23:46:49 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,452 bytes |
コンパイル時間 | 4,009 ms |
コンパイル使用メモリ | 268,004 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-28 00:26:38 |
合計ジャッジ時間 | 12,930 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | WA | - |
testcase_64 | WA | - |
testcase_65 | WA | - |
testcase_66 | WA | - |
testcase_67 | WA | - |
testcase_68 | WA | - |
testcase_69 | WA | - |
testcase_70 | WA | - |
testcase_71 | WA | - |
testcase_72 | WA | - |
testcase_73 | WA | - |
testcase_74 | WA | - |
testcase_75 | WA | - |
testcase_76 | WA | - |
testcase_77 | WA | - |
testcase_78 | WA | - |
testcase_79 | WA | - |
testcase_80 | WA | - |
ソースコード
#include <bits/stdc++.h> using i128 = __int128_t; int sign(i128 a) { return a > 0 ? 1 : a < 0 ? -1 : 0; } const i128 INF = 1e9; struct Qu { i128 a, b; Qu(): a(0), b(0) {} Qu(i128 a_, i128 b_): a(a_), b(b_) { if (b == 0) { a = INF; b = 0; } else { i128 g = std::gcd(std::abs((long long)a), std::abs((long long)b)); a /= g; b /= g; if (sign(a) != sign(b)) { if (b < 0) { a = -a; b = -b; } } else if (a < 0) { a = -a; b = -b; } } } Qu(i128 v): Qu(v, 1) {} }; Qu operator+(Qu lhs, Qu rhs) { i128 b = lhs.b * rhs.b; i128 a = lhs.a * rhs.b + rhs.a * lhs.b; return Qu(a, b); } Qu operator-(Qu lhs, Qu rhs) { i128 b = lhs.b * rhs.b; i128 a = lhs.a * rhs.b - rhs.a * lhs.b; return Qu(a, b); } Qu operator*(Qu lhs, Qu rhs) { return Qu(lhs.a * rhs.a, lhs.b * rhs.b); } Qu operator/(Qu lhs, Qu rhs) { return Qu(lhs.a * rhs.b, lhs.b * rhs.a); } bool eq(Qu lhs, Qu rhs) { return lhs.a == rhs.a && lhs.b == rhs.b; } bool lt(Qu lhs, Qu rhs) { return lhs.a * rhs.b <= rhs.a * lhs.b; } struct Point { Point() {} Point(Qu x, Qu y): x(x), y(y) {} Qu x, y; }; Point mid_point(Point lhs, Point rhs) { return Point((lhs.x + rhs.x) / 2, (lhs.y + rhs.y) / 2); } const Qu UNDEF(INF, 0); struct Line { Qu coef; Qu constant; Line() {} Line(Qu coe, Qu con): coef(coe), constant(con) {} Line(Qu coef, Point point): coef(coef), constant(point.y - point.x * coef) {} }; Qu 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; Qu radius; Circle(Point p, Qu 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++) { int x, y; std::cin >> x >> y; points[i] = Point(x, 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 { Qu 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)) { Qu 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]); Qu dist(0); for (int k = 0; k < 3; k++) { Qu d = distance(mid, points[k]); if (lt(dist, d)) { dist = d; } } if (eq(min_dist, UNDEF) || lt(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); } Qu d = distance(points[0], center); for (int i = 1; i < 3; i++) {} } Qu radius = 0; for (int i = 0; i < 3; i++) { Qu r = distance(center, points[i]); if (lt(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(); }