結果
問題 | No.2602 Real Collider |
ユーザー | nono00 |
提出日時 | 2024-01-13 00:58:59 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,532 bytes |
コンパイル時間 | 8,657 ms |
コンパイル使用メモリ | 449,496 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-28 00:54:53 |
合計ジャッジ時間 | 30,800 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 3 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 882 ms
5,376 KB |
testcase_11 | AC | 262 ms
5,376 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 208 ms
5,376 KB |
testcase_16 | AC | 328 ms
5,376 KB |
testcase_17 | AC | 361 ms
5,376 KB |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 400 ms
5,376 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 185 ms
5,376 KB |
testcase_27 | WA | - |
testcase_28 | AC | 325 ms
5,376 KB |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 341 ms
5,376 KB |
testcase_32 | AC | 287 ms
5,376 KB |
testcase_33 | AC | 349 ms
5,376 KB |
testcase_34 | AC | 315 ms
5,376 KB |
testcase_35 | AC | 205 ms
5,376 KB |
testcase_36 | AC | 179 ms
5,376 KB |
testcase_37 | AC | 355 ms
5,376 KB |
testcase_38 | AC | 351 ms
5,376 KB |
testcase_39 | AC | 352 ms
5,376 KB |
testcase_40 | AC | 165 ms
5,376 KB |
testcase_41 | AC | 392 ms
5,376 KB |
testcase_42 | AC | 309 ms
5,376 KB |
testcase_43 | AC | 309 ms
5,376 KB |
testcase_44 | AC | 422 ms
5,376 KB |
testcase_45 | AC | 252 ms
5,376 KB |
testcase_46 | AC | 241 ms
5,376 KB |
testcase_47 | AC | 374 ms
5,376 KB |
testcase_48 | AC | 268 ms
5,376 KB |
testcase_49 | AC | 239 ms
5,376 KB |
testcase_50 | AC | 178 ms
5,376 KB |
testcase_51 | AC | 199 ms
5,376 KB |
testcase_52 | AC | 139 ms
5,376 KB |
testcase_53 | AC | 333 ms
5,376 KB |
testcase_54 | AC | 249 ms
5,376 KB |
testcase_55 | AC | 282 ms
5,376 KB |
testcase_56 | AC | 286 ms
5,376 KB |
testcase_57 | AC | 255 ms
5,376 KB |
testcase_58 | AC | 95 ms
5,376 KB |
testcase_59 | AC | 319 ms
5,376 KB |
testcase_60 | AC | 262 ms
5,376 KB |
testcase_61 | AC | 209 ms
5,376 KB |
testcase_62 | AC | 327 ms
5,376 KB |
testcase_63 | AC | 368 ms
5,376 KB |
testcase_64 | AC | 450 ms
5,376 KB |
testcase_65 | AC | 216 ms
5,376 KB |
testcase_66 | AC | 354 ms
5,376 KB |
testcase_67 | AC | 156 ms
5,376 KB |
testcase_68 | AC | 191 ms
5,376 KB |
testcase_69 | AC | 127 ms
5,376 KB |
testcase_70 | AC | 158 ms
5,376 KB |
testcase_71 | AC | 210 ms
5,376 KB |
testcase_72 | AC | 312 ms
5,376 KB |
testcase_73 | AC | 256 ms
5,376 KB |
testcase_74 | AC | 328 ms
5,376 KB |
testcase_75 | AC | 350 ms
5,376 KB |
testcase_76 | AC | 307 ms
5,376 KB |
testcase_77 | AC | 312 ms
5,376 KB |
testcase_78 | AC | 420 ms
5,376 KB |
testcase_79 | AC | 333 ms
5,376 KB |
testcase_80 | AC | 388 ms
5,376 KB |
ソースコード
#include <bits/stdc++.h> #include <boost/multiprecision/cpp_int.hpp> #include <boost/rational.hpp> using BigInt = boost::multiprecision::cpp_int; using Rational = boost::rational<BigInt>; 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); } 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() { BigInt INF = 1LL << 60; for (int i = 0; i < 30; i++) INF *= 2; Rational UNDEF(INF); 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(Rational(x), Rational(y)); } std::vector<Line> 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(); }