結果
問題 | No.2602 Real Collider |
ユーザー | nono00 |
提出日時 | 2024-01-12 23:13:36 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,696 bytes |
コンパイル時間 | 3,598 ms |
コンパイル使用メモリ | 266,744 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-27 23:56:18 |
合計ジャッジ時間 | 15,208 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | AC | 2 ms
6,944 KB |
testcase_09 | AC | 2 ms
6,940 KB |
testcase_10 | AC | 228 ms
6,944 KB |
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> int sign(long long a) { return a > 0 ? 1 : a < 0 ? -1 : 0; } const long long INF = 1e9; struct Qu { long long a, b; Qu(): a(0), b(0) {} Qu(long long a_, long long b_): a(a_), b(b_) { if (b == 0) { a = INF; b = 0; } else { long long g = std::gcd(std::abs(a), std::abs(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(long long v): Qu(v, 1) {} }; std::ostream& operator<<(std::ostream& os, Qu q) { os << q.a << '/' << q.b; return os; } Qu operator+(Qu lhs, Qu rhs) { long long b = lhs.b * rhs.b; long long a = lhs.a * rhs.b + rhs.a * lhs.b; return Qu(a, b); } Qu operator-(Qu lhs, Qu rhs) { long long b = lhs.b * rhs.b; long long 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) { Qu l(lhs.a * rhs.b, lhs.b * rhs.b); Qu r(rhs.a * lhs.b, rhs.b * lhs.b); return l.a <= r.a; } 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) {} }; bool eq(Line lhs, Line rhs) { return eq(lhs.coef, rhs.coef) && eq(lhs.constant, rhs.constant); } 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(INF); 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 (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(); }